summaryrefslogtreecommitdiff
path: root/actions/twitapistatuses.php
diff options
context:
space:
mode:
authormac65 <mac65@mac65.com>2008-09-30 20:12:33 -0400
committermac65 <mac65@mac65.com>2008-09-30 20:12:33 -0400
commitc08a67094cb848e8bcd8f631aa44adf57a33b7ab (patch)
treed82c69fdf283483c455759ac6035d5fafaaef7d1 /actions/twitapistatuses.php
parent1c4f7722da90e8e8ce0489720ede223804885377 (diff)
Add support for since_id and before_id to Twitter API. Ticket #540.
darcs-hash:20081001001233-e558a-3fcc269985050021ec9b44c052206c731cc4689d.gz
Diffstat (limited to 'actions/twitapistatuses.php')
-rw-r--r--actions/twitapistatuses.php64
1 files changed, 54 insertions, 10 deletions
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index 4f2139bc5..3271f1e28 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -57,7 +57,22 @@ class TwitapistatusesAction extends TwitterapiAction {
// FIXME: To really live up to the spec we need to build a list
// of notices by users who have custom avatars, so fix this SQL -- Zach
- $notice = Notice::publicStream(0, $MAX_PUBSTATUSES);
+ $page = $this->arg('page');
+ $since_id = $this->arg('since_id');
+ $before_id = $this->arg('before_id');
+
+ // NOTE: page, since_id, and before_id are extensions to Twitter API -- TB
+ if (!$page) {
+ $page = 1;
+ }
+ if (!$since_id) {
+ $since_id = 0;
+ }
+ if (!$before_id) {
+ $before_id = 0;
+ }
+
+ $notice = Notice::publicStream((($page-1)*$MAX_PUBSTATUSES), $MAX_PUBSTATUSES, $since_id, $before_id);
if ($notice) {
@@ -112,16 +127,26 @@ class TwitapistatusesAction extends TwitterapiAction {
$since = $this->arg('since');
$since_id = $this->arg('since_id');
$count = $this->arg('count');
- $page = $this->arg('page');
+ $page = $this->arg('page');
+ $before_id = $this->arg('before_id');
- if (!$page) {
- $page = 1;
- }
+ if (!$page) {
+ $page = 1;
+ }
if (!$count) {
$count = 20;
}
+ if (!$since_id) {
+ $since_id = 0;
+ }
+
+ // NOTE: before_id is an extensions to Twitter API -- TB
+ if (!$before_id) {
+ $before_id = 0;
+ }
+
$user = $this->get_user($id, $apidata);
$profile = $user->getProfile();
@@ -133,7 +158,7 @@ class TwitapistatusesAction extends TwitterapiAction {
$link = common_local_url('all', array('nickname' => $user->nickname));
$subtitle = sprintf(_('Updates from %1$s and friends on %2$s!'), $user->nickname, $sitename);
- $notice = $user->noticesWithFriends(($page-1)*20, $count);
+ $notice = $user->noticesWithFriends(($page-1)*20, $count, $since_id, $before_id);
switch($apidata['content-type']) {
case 'xml':
@@ -215,8 +240,9 @@ class TwitapistatusesAction extends TwitterapiAction {
$count = $this->arg('count');
$since = $this->arg('since');
- $since_id = $this->arg('since_id');
+ $since_id = $this->arg('since_id');
$page = $this->arg('page');
+ $before_id = $this->arg('before_id');
if (!$page) {
$page = 1;
@@ -226,6 +252,15 @@ class TwitapistatusesAction extends TwitterapiAction {
$count = 20;
}
+ if (!$since_id) {
+ $since_id = 0;
+ }
+
+ // NOTE: before_id is an extensions to Twitter API -- TB
+ if (!$before_id) {
+ $before_id = 0;
+ }
+
$sitename = common_config('site', 'name');
$siteserver = common_config('site', 'server');
@@ -235,9 +270,8 @@ class TwitapistatusesAction extends TwitterapiAction {
$subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
# XXX: since
- # XXX: since_id
- $notice = $user->getNotices((($page-1)*20), $count);
+ $notice = $user->getNotices((($page-1)*20), $count, $since_id, $before_id);
switch($apidata['content-type']) {
case 'xml':
@@ -354,6 +388,8 @@ class TwitapistatusesAction extends TwitterapiAction {
$count = $this->arg('count');
$page = $this->arg('page');
+ $since_id = $this->arg('since_id');
+ $before_id = $this->arg('before_id');
$user = $apidata['user'];
$profile = $user->getProfile();
@@ -374,7 +410,15 @@ class TwitapistatusesAction extends TwitterapiAction {
$count = 20;
}
- $notice = $user->getReplies((($page-1)*20), $count);
+ if (!$since_id) {
+ $since_id = 0;
+ }
+
+ // NOTE: before_id is an extensions to Twitter API -- TB
+ if (!$before_id) {
+ $before_id = 0;
+ }
+ $notice = $user->getReplies((($page-1)*20), $count, $since_id, $before_id);
$notices = array();
while ($notice->fetch()) {