summaryrefslogtreecommitdiff
path: root/scripts/twitterstatusfetcher.php
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/twitterstatusfetcher.php')
-rwxr-xr-xscripts/twitterstatusfetcher.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php
index 68f7e9bf7..3cdf1867a 100755
--- a/scripts/twitterstatusfetcher.php
+++ b/scripts/twitterstatusfetcher.php
@@ -148,9 +148,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 +161,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());
}