Created
August 25, 2012 12:35
-
-
Save mrvdb/3464967 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php | |
| index 06ce430..723a561 100755 | |
| --- a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php | |
| +++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php | |
| @@ -171,6 +171,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon | |
| } | |
| $timeline = null; | |
| + $mentions = null; | |
| $lastId = Twitter_synch_status::getLastId($flink->foreign_id, 'home_timeline'); | |
| @@ -178,13 +179,17 @@ class TwitterStatusFetcher extends ParallelizingDaemon | |
| try { | |
| $timeline = $client->statusesHomeTimeline($lastId); | |
| + $mentions = $client->statusesMentions($lastId); | |
| } catch (Exception $e) { | |
| common_log(LOG_WARNING, $this->name() . | |
| - ' - Twitter client unable to get friends timeline for user ' . | |
| + ' - Twitter client unable to get friends/mentions timeline for user ' . | |
| $flink->user_id . ' - code: ' . | |
| $e->getCode() . 'msg: ' . $e->getMessage()); | |
| } | |
| + // Merge the two arrays of mentions and timelines | |
| + $timeline = array_merge($timeline, $mentions); | |
| + | |
| if (empty($timeline)) { | |
| common_log(LOG_WARNING, $this->name() . " - Empty timeline."); | |
| return; | |
| diff --git a/plugins/TwitterBridge/twitteroauthclient.php b/plugins/TwitterBridge/twitteroauthclient.php | |
| index a17911b..5d691d8 100644 | |
| --- a/plugins/TwitterBridge/twitteroauthclient.php | |
| +++ b/plugins/TwitterBridge/twitteroauthclient.php | |
| @@ -223,6 +223,38 @@ class TwitterOAuthClient extends OAuthClient | |
| } | |
| /** | |
| + * Calls Twitter's /statuses/mentions API method | |
| + * | |
| + * @param int $since_id show statuses after this id | |
| + * @param int $max_id show statuses before this id | |
| + * @param int $page page number | |
| + * | |
| + * @return mixed an array of statuses | |
| + */ | |
| + function statusesMentions($since_id = null, $max_id = null, | |
| + $page = null) | |
| + { | |
| + $url = 'https://api.twitter.com/1/statuses/mentions.json'; | |
| + | |
| + $params = array('include_entities' => 'true'); | |
| + | |
| + if (!empty($since_id)) { | |
| + $params['since_id'] = $since_id; | |
| + } | |
| + if (!empty($max_id)) { | |
| + $params['max_id'] = $max_id; | |
| + } | |
| + if (!empty($page)) { | |
| + $params['page'] = $page; | |
| + } | |
| + | |
| + $response = $this->oAuthGet($url, $params); | |
| + $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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment