diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-08-28 07:03:32 +0000 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-08-28 07:03:32 +0000 |
commit | ca30cc2d594acabefeafa61edb61342b32752bc1 (patch) | |
tree | 8e843c7ecbaeb7c160495e18f7407acade4aa117 /scripts/synctwitterfriends.php | |
parent | c0d03fc2799c7b0c57d05166b404a3d13427f497 (diff) | |
parent | 36c104fb34d7128a0372dd3f77504c0b2f76ba80 (diff) |
Merge branch 'twitter-basic-auth' into 0.8.x
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() . ' - ' . |