// 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
$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
$authorize_url .= '&oauth_callback=' . urlencode($oauth_callback);
}
- common_debug("$authorize_url");
-
return $authorize_url;
}
// 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;
$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
*
{
$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();
// 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;