- Implement statusesHomeTimeline() in TwitterBasicAuthClient

- Make TwitterStatusFetcher pull home_timeline (includes retweets) instead of friends_timeline
This commit is contained in:
Zach Copley 2010-05-27 11:21:52 -07:00
parent bcca10f526
commit 4211b7f011
3 changed files with 32 additions and 3 deletions

View File

@ -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 ' .

View File

@ -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
*
@ -125,6 +125,35 @@ class TwitterBasicAuthClient
return $statuses;
}
/**
* 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
*

View File

@ -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)