X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Ftwitterstatusfetcher.php;h=3cdf1867a197319c486d61bab7c19d8edf735fd8;hb=c9eb7c1f0b60cbcf4672bcfca0814dd1bfc1dcf0;hp=082bcc9622a5b929e85bc947a21d547ff08afa45;hpb=ff87732053bae38879988ba7d002a294998ccb4e;p=quix0rs-gnu-social.git diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php index 082bcc9622..3cdf1867a1 100755 --- a/scripts/twitterstatusfetcher.php +++ b/scripts/twitterstatusfetcher.php @@ -1,8 +1,8 @@ #!/usr/bin/env php - * @author Evan Prodromou + * @package StatusNet + * @author Zach Copley + * @author Evan Prodromou * @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 { @@ -97,10 +97,6 @@ class TwitterStatusFetcher extends ParallelizingDaemon { global $_DB_DATAOBJECT; -======= - global $_DB_DATAOBJECT; - ->>>>>>> 0.8.x:scripts/twitterstatusfetcher.php $flink = new Foreign_link(); $conn = &$flink->getDatabaseConnection(); @@ -152,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; } @@ -165,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()); } @@ -189,7 +192,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon foreach (array_reverse($timeline) as $status) { - // Hacktastic: filter out stuff coming from this Laconica + // Hacktastic: filter out stuff coming from this StatusNet $source = mb_strtolower(common_config('integration', 'source')); @@ -482,7 +485,7 @@ class TwitterStatusFetcher extends ParallelizingDaemon default: // Note: Twitter's big avatars are a different size than - // Laconica's (Laconica's = 96) + // StatusNet's (StatusNet's = 96) $avatar->width = 73; $avatar->height = 73;