]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/twitterstatusfetcher.php
Bug 1969: rebuild corrupted l10n files which caused all UI strings to be shown as...
[quix0rs-gnu-social.git] / scripts / twitterstatusfetcher.php
index 0b5caed011a163668375c92806ab11dd88cfc456..3cdf1867a197319c486d61bab7c19d8edf735fd8 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env php
 <?php
 /**
- * StatusNet - a distributed open-source microblogging tool
+ * StatusNet - the distributed open-source microblogging tool
  * Copyright (C) 2008, 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
@@ -47,14 +47,14 @@ require_once INSTALLDIR . '/lib/daemon.php';
  *
  * @category Twitter
  * @package  StatusNet
- * @author   Zach Copley <zach@controlyourself.ca>
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @author   Zach Copley <zach@status.net>
+ * @author   Evan Prodromou <evan@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  */
 
 // NOTE: an Avatar path MUST be set in config.php for this
-// script to work: e.g.: $config['avatar']['path'] = '/laconica/avatar';
+// script to work: e.g.: $config['avatar']['path'] = '/statusnet/avatar';
 
 class TwitterStatusFetcher extends ParallelizingDaemon
 {
@@ -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());
         }
@@ -478,7 +485,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon
         default:
 
             // Note: Twitter's big avatars are a different size than
-            // StatusNet's (Laconica's = 96)
+            // StatusNet's (StatusNet's = 96)
 
             $avatar->width  = 73;
             $avatar->height = 73;