From 36c104fb34d7128a0372dd3f77504c0b2f76ba80 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 28 Aug 2009 07:02:27 +0000 Subject: Make SyncTwitterFriends and TwitterStatusFetcher daemons use both HTTP Basic Auth as well as OAuth --- scripts/synctwitterfriends.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'scripts/synctwitterfriends.php') diff --git a/scripts/synctwitterfriends.php b/scripts/synctwitterfriends.php index 545cb23b3..2cb7525ea 100755 --- a/scripts/synctwitterfriends.php +++ b/scripts/synctwitterfriends.php @@ -19,6 +19,8 @@ */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); +define('STATUSNET', true); +define('LACONICA', true); // compatibility $shortoptions = 'di::'; $longoptions = array('id::', 'debug'); @@ -142,13 +144,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()); @@ -177,7 +186,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() . ' - ' . -- cgit v1.2.3-54-g00ecf From a0a376bf0eca00cce974de12c2f275006c1281ee Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 28 Aug 2009 17:55:58 +0000 Subject: Take out unnecessary defines --- scripts/synctwitterfriends.php | 2 -- scripts/twitterqueuehandler.php | 2 -- scripts/twitterstatusfetcher.php | 2 -- 3 files changed, 6 deletions(-) (limited to 'scripts/synctwitterfriends.php') diff --git a/scripts/synctwitterfriends.php b/scripts/synctwitterfriends.php index 2cb7525ea..b30e700a1 100755 --- a/scripts/synctwitterfriends.php +++ b/scripts/synctwitterfriends.php @@ -19,8 +19,6 @@ */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('STATUSNET', true); -define('LACONICA', true); // compatibility $shortoptions = 'di::'; $longoptions = array('id::', 'debug'); diff --git a/scripts/twitterqueuehandler.php b/scripts/twitterqueuehandler.php index 992141f9d..ce4d824d0 100755 --- a/scripts/twitterqueuehandler.php +++ b/scripts/twitterqueuehandler.php @@ -19,8 +19,6 @@ */ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('STATUSNET', true); -define('LACONICA', true); // compatibility $shortoptions = 'i::'; $longoptions = array('id::'); diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php index 6dca6f75b..3cdf1867a 100755 --- a/scripts/twitterstatusfetcher.php +++ b/scripts/twitterstatusfetcher.php @@ -19,8 +19,6 @@ */ 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? -- cgit v1.2.3-54-g00ecf