From 088081675fb7d5250a9b9dfe5015de0822cb5ac2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 9 Nov 2009 20:01:46 +0100 Subject: Revert "Remove more contractions" This reverts commit 5ab709b73977131813884558bf56d97172a7aa26. Missed this one yesterday... --- lib/api.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/api.php') diff --git a/lib/api.php b/lib/api.php index fb4c4289b..a1236ab7e 100644 --- a/lib/api.php +++ b/lib/api.php @@ -66,7 +66,7 @@ class ApiAction extends Action * * @param array $args Web and URL arguments * - * @return boolean false if user does not exist + * @return boolean false if user doesn't exist */ function prepare($args) @@ -138,7 +138,7 @@ class ApiAction extends Action $design = null; $user = $profile->getUser(); - // Note: some profiles do not have an associated user + // Note: some profiles don't have an associated user if (!empty($user)) { $design = $user->getDesign(); @@ -203,7 +203,7 @@ class ApiAction extends Action if ($get_notice) { $notice = $profile->getCurrentNotice(); if ($notice) { - # do not get user! + # don't get user! $twitter_user['status'] = $this->twitterStatusArray($notice, false); } } @@ -263,7 +263,7 @@ class ApiAction extends Action } if ($include_user) { - # Do not get notice (recursive!) + # Don't get notice (recursive!) $twitter_user = $this->twitterUserArray($profile, false); $twitter_status['user'] = $twitter_user; } @@ -1074,7 +1074,7 @@ class ApiAction extends Action function initTwitterAtom() { $this->startXML(); - // FIXME: do not hardcode the language here! + // FIXME: don't hardcode the language here! $this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en-US', 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0')); @@ -1116,7 +1116,7 @@ class ApiAction extends Action return User::staticGet('nickname', $nickname); } else if ($this->arg('user_id')) { // This is to ensure that a non-numeric user_id still - // overrides screen_name even if it does not get used + // overrides screen_name even if it doesn't get used if (is_numeric($this->arg('user_id'))) { return User::staticGet('id', $this->arg('user_id')); } @@ -1146,7 +1146,7 @@ class ApiAction extends Action return User_group::staticGet('nickname', $nickname); } else if ($this->arg('group_id')) { // This is to ensure that a non-numeric user_id still - // overrides screen_name even if it does not get used + // overrides screen_name even if it doesn't get used if (is_numeric($this->arg('group_id'))) { return User_group::staticGet('id', $this->arg('group_id')); } -- cgit v1.2.3-54-g00ecf From cb64cfb44c7bf08f113444ccdde4b9a4b7fa6808 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 10 Nov 2009 16:15:05 -0500 Subject: add geo output to statuses in json, xml, atom, rss in API --- classes/Notice.php | 6 ++++++ lib/api.php | 45 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 7 deletions(-) (limited to 'lib/api.php') diff --git a/classes/Notice.php b/classes/Notice.php index 9886875cb..291e6202b 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1254,6 +1254,12 @@ class Notice extends Memcached_DataObject } } + if (!empty($this->lat) && !empty($this->lon)) { + $xs->elementStart('geo', array('xmlns:georss' => 'http://www.georss.org/georss')); + $xs->element('georss:point', null, $this->lat . ' ' . $this->lon); + $xs->elementEnd('geo'); + } + $xs->elementEnd('entry'); return $xs->getString(); diff --git a/lib/api.php b/lib/api.php index a1236ab7e..5e66639c4 100644 --- a/lib/api.php +++ b/lib/api.php @@ -60,7 +60,7 @@ class ApiAction extends Action var $max_id = null; var $since_id = null; var $since = null; - + /** * Initialization. * @@ -72,14 +72,14 @@ class ApiAction extends Action function prepare($args) { parent::prepare($args); - + $this->format = $this->arg('format'); $this->page = (int)$this->arg('page', 1); $this->count = (int)$this->arg('count', 20); $this->max_id = (int)$this->arg('max_id', 0); $this->since_id = (int)$this->arg('since_id', 0); $this->since = $this->arg('since'); - + return true; } @@ -164,7 +164,6 @@ class ApiAction extends Action $twitter_user['favourites_count'] = $profile->faveCount(); // British spelling! - $timezone = 'UTC'; if ($user->timezone) { @@ -238,6 +237,15 @@ class ApiAction extends Action $twitter_status['in_reply_to_screen_name'] = ($replier_profile) ? $replier_profile->nickname : null; + if (isset($notice->lat) && isset($notice->lon)) { + // This is the format that GeoJSON expects stuff to be in + $twitter_status['geo'] = array('type' => 'Point', + 'coordinates' => array((float) $notice->lat, + (float) $notice->lon)); + } else { + $twitter_status['geo'] = null; + } + if (isset($this->auth_user)) { $twitter_status['favorited'] = $this->auth_user->hasFave($notice); } else { @@ -362,10 +370,19 @@ class ApiAction extends Action $entry['pubDate'] = common_date_rfc2822($notice->created); $entry['guid'] = $entry['link']; + if (isset($notice->lat) && isset($notice->lon)) { + // This is the format that GeoJSON expects stuff to be in. + // showGeoRSS() below uses it for XML output, so we reuse it + $entry['geo'] = array('type' => 'Point', + 'coordinates' => array((float) $notice->lat, + (float) $notice->lon)); + } else { + $entry['geo'] = null; + } + return $entry; } - function twitterRelationshipArray($source, $target) { $relationship = array(); @@ -441,6 +458,9 @@ class ApiAction extends Action case 'attachments': $this->showXmlAttachments($twitter_status['attachments']); break; + case 'geo': + $this->showGeoRSS($value); + break; default: $this->element($element, null, $value); } @@ -484,6 +504,18 @@ class ApiAction extends Action } } + function showGeoRSS($geo) + { + if (empty($geo)) { + // empty geo element + $this->element('geo'); + } else { + $this->elementStart('geo', array('xmlns:georss' => 'http://www.georss.org/georss')); + $this->element('georss:point', null, $geo['coordinates'][0] . ' ' . $geo['coordinates'][1]); + $this->elementEnd('geo'); + } + } + function showTwitterRssItem($entry) { $this->elementStart('item'); @@ -505,6 +537,7 @@ class ApiAction extends Action } } + $this->showGeoRSS($entry['geo']); $this->elementEnd('item'); } @@ -529,7 +562,6 @@ class ApiAction extends Action $this->endDocument('json'); } - function showXmlTimeline($notice) { @@ -649,7 +681,6 @@ class ApiAction extends Action $this->endTwitterRss(); } - function showTwitterAtomEntry($entry) { $this->elementStart('entry'); -- cgit v1.2.3-54-g00ecf