summaryrefslogtreecommitdiff
path: root/actions/twitapistatuses.php
diff options
context:
space:
mode:
authorzach <zach@copley.name>2008-07-16 02:09:22 -0400
committerzach <zach@copley.name>2008-07-16 02:09:22 -0400
commit8977032e112ee09c8c95a838b46dbb14f5aee0be (patch)
tree669258a6026fe7adcece20c64b70c9ac240e6c16 /actions/twitapistatuses.php
parent110ce8c811fb6f48e17b5bd78eaa0741a26e55a5 (diff)
Twitter-compatible API: public_timeline.json now works
darcs-hash:20080716060922-ca946-6e973c6fb40ab8c8c930b6dfd916e20f40545471.gz
Diffstat (limited to 'actions/twitapistatuses.php')
-rw-r--r--actions/twitapistatuses.php35
1 files changed, 26 insertions, 9 deletions
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index bb30049ee..83fd4b53c 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -38,16 +38,17 @@ class TwitapistatusesAction extends TwitterapiAction {
function public_timeline($args, $apidata) {
parent::handle($args);
- if ($apidata['content-type'] == 'xml') {
- header('Content-Type: application/xml; charset=utf-8');
- $notice = DB_DataObject::factory('notice');
+ $notice = DB_DataObject::factory('notice');
- # FIXME: bad performance
- $notice->whereAdd('EXISTS (SELECT user.id from user where user.id = notice.profile_id)');
- $notice->orderBy('created DESC, notice.id DESC');
- $notice->limit(20);
- $cnt = $notice->find();
+ # FIXME: bad performance
+ $notice->whereAdd('EXISTS (SELECT user.id from user where user.id = notice.profile_id)');
+ $notice->orderBy('created DESC, notice.id DESC');
+ $notice->limit(20);
+ $cnt = $notice->find();
+ if ($apidata['content-type'] == 'xml') {
+ header('Content-Type: application/xml; charset=utf-8');
+
common_start_xml();
// XXX: To really live up to the spec we need to build a list
@@ -72,7 +73,23 @@ class TwitapistatusesAction extends TwitterapiAction {
} elseif ($apidata['content-type'] == 'atom') {
common_server_error("API method under construction.", $code=501);
} elseif ($apidata['content-type'] == 'json') {
- common_server_error("API method under construction.", $code=501);
+
+ header('Content-Type: application/json; charset=utf-8');
+
+ $statuses = array();
+
+ if ($cnt > 0) {
+ for ($i = 0; $i < 20; $i++) {
+ if ($notice->fetch()) {
+ $twitter_status = $this->twitter_status_array($notice);
+ array_push($statuses, $twitter_status);
+ } else {
+ // shouldn't happen!
+ break;
+ }
+ }
+ }
+ $this->render_twitter_json_statuses($statuses);
}
exit();