diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-02-22 20:04:47 -0800 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-02-22 20:04:47 -0800 |
commit | cab322d21b8c8077192a1396bf13050d734c2aba (patch) | |
tree | 15d547a28f1669a65ac0ce2720bc1b89e15043ee /actions/twitapistatuses.php | |
parent | 5e646ead492fc62b52f67af6c3a23295ef502345 (diff) |
Ticket #1108 - Added 'social graph' methods to the API
Diffstat (limited to 'actions/twitapistatuses.php')
-rw-r--r-- | actions/twitapistatuses.php | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index 51c256589..216835026 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -470,19 +470,28 @@ class TwitapistatusesAction extends TwitterapiAction return $this->subscriptions($apidata, 'subscribed', 'subscriber'); } - function followers($args, $apidata) + function friendsIDs($args, $apidata) { parent::handle($args); + return $this->subscriptions($apidata, 'subscribed', 'subscriber', true); + } + function followers($args, $apidata) + { + parent::handle($args); return $this->subscriptions($apidata, 'subscriber', 'subscribed'); } - function subscriptions($apidata, $other_attr, $user_attr) + function followersIDs($args, $apidata) { + parent::handle($args); + return $this->subscriptions($apidata, 'subscriber', 'subscribed', true); + } - # XXX: lite + function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs=false) + { - $this->auth_user = $apidate['user']; + $this->auth_user = $apidata['user']; $user = $this->get_user($apidata['api_arg'], $apidata); if (!$user) { @@ -514,7 +523,10 @@ class TwitapistatusesAction extends TwitterapiAction } $sub->orderBy('created DESC'); - $sub->limit(($page-1)*100, 100); + + if (!$onlyIDs) { + $sub->limit(($page-1)*100, 100); + } $others = array(); @@ -529,7 +541,13 @@ class TwitapistatusesAction extends TwitterapiAction $type = $apidata['content-type']; $this->init_document($type); - $this->show_profiles($others, $type); + + if ($onlyIDs) { + $this->showIDs($others, $type); + } else { + $this->show_profiles($others, $type); + } + $this->end_document($type); } @@ -555,6 +573,28 @@ class TwitapistatusesAction extends TwitterapiAction } } + function showIDs($profiles, $type) + { + switch ($type) { + case 'xml': + $this->elementStart('ids'); + foreach ($profiles as $profile) { + $this->element('id', null, $profile->id); + } + $this->elementEnd('ids'); + break; + case 'json': + $ids = array(); + foreach ($profiles as $profile) { + $ids[] = (int)$profile->id; + } + print json_encode($ids); + break; + default: + $this->clientError(_('unsupported file type')); + } + } + function featured($args, $apidata) { parent::handle($args); |