diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-08-28 07:03:32 +0000 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-08-28 07:03:32 +0000 |
commit | ca30cc2d594acabefeafa61edb61342b32752bc1 (patch) | |
tree | 8e843c7ecbaeb7c160495e18f7407acade4aa117 /scripts/twitterstatusfetcher.php | |
parent | c0d03fc2799c7b0c57d05166b404a3d13427f497 (diff) | |
parent | 36c104fb34d7128a0372dd3f77504c0b2f76ba80 (diff) |
Merge branch 'twitter-basic-auth' into 0.8.x
Diffstat (limited to 'scripts/twitterstatusfetcher.php')
-rwxr-xr-x | scripts/twitterstatusfetcher.php | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php index 68f7e9bf7..6dca6f75b 100755 --- a/scripts/twitterstatusfetcher.php +++ b/scripts/twitterstatusfetcher.php @@ -19,6 +19,8 @@ */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('STATUSNET', true); +define('LACONICA', true); // compatibility // Tune number of processes and how often to poll Twitter // XXX: Should these things be in config.php? @@ -148,9 +150,9 @@ class TwitterStatusFetcher extends ParallelizingDaemon function getTimeline($flink) { - if (empty($flink)) { + if (empty($flink)) { common_log(LOG_WARNING, $this->name() . - " - Can't retrieve Foreign_link for foreign ID $fid"); + " - Can't retrieve Foreign_link for foreign ID $fid"); return; } @@ -161,17 +163,24 @@ class TwitterStatusFetcher extends ParallelizingDaemon // to start importing? How many statuses? Right now I'm going // with the default last 20. - $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = null; - $client = new TwitterOAuthClient($token->key, $token->secret); + if (TwitterOAuthClient::isPackedToken($flink->credentials)) { + $token = TwitterOAuthClient::unpackToken($flink->credentials); + $client = new TwitterOAuthClient($token->key, $token->secret); + common_debug($this->name() . ' - Grabbing friends timeline with OAuth.'); + } else { + $client = new TwitterBasicAuthClient($flink); + common_debug($this->name() . ' - Grabbing friends timeline with basic auth.'); + } $timeline = null; try { $timeline = $client->statusesFriendsTimeline(); - } catch (OAuthClientCurlException $e) { + } catch (Exception $e) { common_log(LOG_WARNING, $this->name() . - ' - OAuth client unable to get friends timeline for user ' . + ' - Twitter client unable to get friends timeline for user ' . $flink->user_id . ' - code: ' . $e->getCode() . 'msg: ' . $e->getMessage()); } |