summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/twitterauthorization.php8
-rw-r--r--lib/oauthclient.php2
-rw-r--r--lib/twitter.php4
-rw-r--r--lib/twitteroauthclient.php17
-rwxr-xr-xscripts/synctwitterfriends.php4
-rwxr-xr-xscripts/twitterstatusfetcher.php4
6 files changed, 31 insertions, 8 deletions
diff --git a/actions/twitterauthorization.php b/actions/twitterauthorization.php
index c40f27164..b04f35327 100644
--- a/actions/twitterauthorization.php
+++ b/actions/twitterauthorization.php
@@ -113,7 +113,7 @@ class TwitterauthorizationAction extends Action
// Get a new request token and authorize it
$client = new TwitterOAuthClient();
- $req_tok =
+ $req_tok =
$client->getRequestToken(TwitterOAuthClient::$requestTokenURL);
// Sock the request token away in the session temporarily
@@ -198,8 +198,10 @@ class TwitterauthorizationAction extends Action
$flink->user_id = $user->id;
$flink->foreign_id = $twitter_user->id;
$flink->service = TWITTER_SERVICE;
- $flink->token = $access_token->key;
- $flink->credentials = $access_token->secret;
+
+ $creds = TwitterOAuthClient::packToken($access_token);
+
+ $flink->credentials = $creds;
$flink->created = common_sql_now();
// Defaults: noticesync on, everything else off
diff --git a/lib/oauthclient.php b/lib/oauthclient.php
index 878e47091..b66a24be4 100644
--- a/lib/oauthclient.php
+++ b/lib/oauthclient.php
@@ -121,8 +121,6 @@ class OAuthClient
$authorize_url .= '&oauth_callback=' . urlencode($oauth_callback);
}
- common_debug("$authorize_url");
-
return $authorize_url;
}
diff --git a/lib/twitter.php b/lib/twitter.php
index 4e2f67c66..280cdb0a3 100644
--- a/lib/twitter.php
+++ b/lib/twitter.php
@@ -160,7 +160,9 @@ function broadcast_twitter($notice)
// XXX: Hack to get around PHP cURL's use of @ being a a meta character
$statustxt = preg_replace('/^@/', ' @', $notice->content);
- $client = new TwitterOAuthClient($flink->token, $flink->credentials);
+ $token = TwitterOAuthClient::unpackToken($flink->credentials);
+
+ $client = new TwitterOAuthClient($token->key, $token->secret);
$status = null;
diff --git a/lib/twitteroauthclient.php b/lib/twitteroauthclient.php
index c798ac877..b7dc4a80c 100644
--- a/lib/twitteroauthclient.php
+++ b/lib/twitteroauthclient.php
@@ -64,6 +64,23 @@ class TwitterOAuthClient extends OAuthClient
$oauth_token, $oauth_token_secret);
}
+ // XXX: the following two functions are to support the horrible hack
+ // of using the credentils field in Foreign_link to store both
+ // the access token and token secret. This hack should go away with
+ // 0.9, in which we can make DB changes and add a new column for the
+ // token itself.
+
+ static function packToken($token)
+ {
+ return implode(chr(0), array($token->key, $token->secret));
+ }
+
+ static function unpackToken($str)
+ {
+ $vals = explode(chr(0), $str);
+ return new OAuthToken($vals[0], $vals[1]);
+ }
+
/**
* Builds a link to Twitter's endpoint for authorizing a request token
*
diff --git a/scripts/synctwitterfriends.php b/scripts/synctwitterfriends.php
index 39b9ad612..d13500e97 100755
--- a/scripts/synctwitterfriends.php
+++ b/scripts/synctwitterfriends.php
@@ -142,7 +142,9 @@ class SyncTwitterFriendsDaemon extends ParallelizingDaemon
{
$friends = array();
- $client = new TwitterOAuthClient($flink->token, $flink->credentials);
+ $token = TwitterOAuthClient::unpackToken($flink->credentials);
+
+ $client = new TwitterOAuthClient($token->key, $token->secret);
try {
$friends_ids = $client->friendsIds();
diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php
index e04a8993f..f5289c5f4 100755
--- a/scripts/twitterstatusfetcher.php
+++ b/scripts/twitterstatusfetcher.php
@@ -161,7 +161,9 @@ class TwitterStatusFetcher extends ParallelizingDaemon
// to start importing? How many statuses? Right now I'm going
// with the default last 20.
- $client = new TwitterOAuthClient($flink->token, $flink->credentials);
+ $token = TwitterOAuthClient::unpackToken($flink->credentials);
+
+ $client = new TwitterOAuthClient($token->key, $token->secret);
$timeline = null;