summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-05-27 11:21:52 -0700
committerZach Copley <zach@status.net>2010-05-27 11:21:52 -0700
commit4211b7f01188b4ab64407e32b380366a048102f4 (patch)
tree0fac58d8df20be109847b068f73de985a13408b4
parentbcca10f5268ac2c2945479dd93d2f302478e02f9 (diff)
- Implement statusesHomeTimeline() in TwitterBasicAuthClient
- Make TwitterStatusFetcher pull home_timeline (includes retweets) instead of friends_timeline
-rwxr-xr-xplugins/TwitterBridge/daemons/twitterstatusfetcher.php2
-rw-r--r--plugins/TwitterBridge/twitterbasicauthclient.php31
-rw-r--r--plugins/TwitterBridge/twitteroauthclient.php2
3 files changed, 32 insertions, 3 deletions
diff --git a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
index 7c624fdb3..03a4bd3f3 100755
--- a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
+++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
@@ -186,7 +186,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon
$timeline = null;
try {
- $timeline = $client->statusesFriendsTimeline();
+ $timeline = $client->statusesHomeTimeline();
} catch (Exception $e) {
common_log(LOG_WARNING, $this->name() .
' - Twitter client unable to get friends timeline for user ' .
diff --git a/plugins/TwitterBridge/twitterbasicauthclient.php b/plugins/TwitterBridge/twitterbasicauthclient.php
index 2c18c9469..cc68b5010 100644
--- a/plugins/TwitterBridge/twitterbasicauthclient.php
+++ b/plugins/TwitterBridge/twitterbasicauthclient.php
@@ -2,7 +2,7 @@
/**
* StatusNet, the distributed open-source microblogging tool
*
- * Class for doing OAuth calls against Twitter
+ * Class for doing HTTP basic auth calls against Twitter
*
* PHP version 5
*
@@ -126,6 +126,35 @@ class TwitterBasicAuthClient
}
/**
+ * Calls Twitter's /statuses/home_timeline API method
+ *
+ * @param int $since_id show statuses after this id
+ * @param int $max_id show statuses before this id
+ * @param int $cnt number of statuses to show
+ * @param int $page page number
+ *
+ * @return mixed an array of statuses similar to friends timeline but including retweets
+ */
+ function statusesFriendsTimeline($since_id = null, $max_id = null,
+ $cnt = null, $page = null)
+ {
+ $url = 'https://twitter.com/statuses/home_timeline.json';
+ $params = array('since_id' => $since_id,
+ 'max_id' => $max_id,
+ 'count' => $cnt,
+ 'page' => $page);
+ $qry = http_build_query($params);
+
+ if (!empty($qry)) {
+ $url .= "?$qry";
+ }
+
+ $response = $this->httpRequest($url);
+ $statuses = json_decode($response);
+ return $statuses;
+ }
+
+ /**
* Calls Twitter's /statuses/friends API method
*
* @param int $id id of the user whom you wish to see friends of
diff --git a/plugins/TwitterBridge/twitteroauthclient.php b/plugins/TwitterBridge/twitteroauthclient.php
index 6b821ba18..f6ef78675 100644
--- a/plugins/TwitterBridge/twitteroauthclient.php
+++ b/plugins/TwitterBridge/twitteroauthclient.php
@@ -225,7 +225,7 @@ class TwitterOAuthClient extends OAuthClient
* @param int $cnt number of statuses to show
* @param int $page page number
*
- * @return mixed an array of statuses, similare to friends_timeline, except including retweets
+ * @return mixed an array of statuses, similar to friends_timeline but including retweets
*/
function statusesHomeTimeline($since_id = null, $max_id = null,
$cnt = null, $page = null)