diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-08-28 07:02:27 +0000 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-08-28 07:02:27 +0000 |
commit | 36c104fb34d7128a0372dd3f77504c0b2f76ba80 (patch) | |
tree | 95c03e5a3b0e3b096e3d1febf4ce21a562507bfb /scripts/synctwitterfriends.php | |
parent | 36b6ef8d05bf6e4290894f9677cc9618a9bfd486 (diff) |
Make SyncTwitterFriends and TwitterStatusFetcher daemons use both HTTP Basic Auth as well as OAuth
Diffstat (limited to 'scripts/synctwitterfriends.php')
-rwxr-xr-x | scripts/synctwitterfriends.php | 17 |
1 files changed, 13 insertions, 4 deletions
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() . ' - ' . |