summaryrefslogtreecommitdiff
path: root/plugins/TwitterBridge/daemons
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2009-09-08 16:02:57 -0700
committerZach Copley <zach@controlyourself.ca>2009-09-08 16:02:57 -0700
commit9d87313eaebe8240393ac300a435f3b1332c8849 (patch)
tree6b7e7d69c63fc6801ad95477be9c11ccb7cd0a1a /plugins/TwitterBridge/daemons
parent5efe588174c71979fc1970353c9a556ea441f138 (diff)
parentbeae3db41375879e725af053edf8041bbd76ac8c (diff)
Merge branch '0.9.x' into pluginize-twitter-bridge
Conflicts: plugins/TwitterBridge/twitterauthorization.php
Diffstat (limited to 'plugins/TwitterBridge/daemons')
-rwxr-xr-xplugins/TwitterBridge/daemons/synctwitterfriends.php27
-rwxr-xr-xplugins/TwitterBridge/daemons/twitterqueuehandler.php4
-rwxr-xr-xplugins/TwitterBridge/daemons/twitterstatusfetcher.php37
3 files changed, 41 insertions, 27 deletions
diff --git a/plugins/TwitterBridge/daemons/synctwitterfriends.php b/plugins/TwitterBridge/daemons/synctwitterfriends.php
index b7be5d043..0668c6222 100755
--- a/plugins/TwitterBridge/daemons/synctwitterfriends.php
+++ b/plugins/TwitterBridge/daemons/synctwitterfriends.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * 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
* it under the terms of the GNU Affero General Public License as published by
@@ -38,11 +38,11 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
* Daemon to sync local friends with Twitter friends
*
* @category Twitter
- * @package Laconica
- * @author Zach Copley <zach@controlyourself.ca>
- * @author Evan Prodromou <evan@controlyourself.ca>
+ * @package StatusNet
+ * @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/
*/
$helptext = <<<END_OF_TWITTER_HELP
@@ -143,13 +143,20 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
{
$friends = array();
- $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 IDs with OAuth.');
+ } else {
+ $client = new TwitterBasicAuthClient($flink);
+ common_debug($this->name() . '- Grabbing friends IDs with basic auth.');
+ }
try {
$friends_ids = $client->friendsIds();
- } catch (OAuthCurlException $e) {
+ } catch (Exception $e) {
common_log(LOG_WARNING, $this->name() .
' - cURL error getting friend ids ' .
$e->getCode() . ' - ' . $e->getMessage());
@@ -178,7 +185,7 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
try {
$more_friends = $client->statusesFriends(null, null, null, $i);
- } catch (OAuthCurlException $e) {
+ } catch (Exception $e) {
common_log(LOG_WARNING, $this->name() .
' - cURL error getting Twitter statuses/friends ' .
"page $i - " . $e->getCode() . ' - ' .
diff --git a/plugins/TwitterBridge/daemons/twitterqueuehandler.php b/plugins/TwitterBridge/daemons/twitterqueuehandler.php
index 9aa9d1ed0..f0e76bb74 100755
--- a/plugins/TwitterBridge/daemons/twitterqueuehandler.php
+++ b/plugins/TwitterBridge/daemons/twitterqueuehandler.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * 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
* it under the terms of the GNU Affero General Public License as published by
diff --git a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
index 3023bf423..4752ada7c 100755
--- a/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
+++ b/plugins/TwitterBridge/daemons/twitterstatusfetcher.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/**
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * 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
* it under the terms of the GNU Affero General Public License as published by
@@ -47,15 +47,15 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitter.php';
* system.
*
* @category Twitter
- * @package Laconica
- * @author Zach Copley <zach@controlyourself.ca>
- * @author Evan Prodromou <evan@controlyourself.ca>
+ * @package StatusNet
+ * @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
{
@@ -149,9 +149,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;
}
@@ -162,17 +162,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());
}
@@ -186,7 +193,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'));
@@ -479,7 +486,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;