X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ftwitterauthorization.php;h=630ac426fd02248251472a0e1117a0115f102a7a;hb=affe00276a008038e8a8b37b3812215e382fe98e;hp=cf27d69cf10244bd817eca3be6d3580c759dd627;hpb=df12206421ca74b5c352bb663ca43e9aabe667fd;p=quix0rs-gnu-social.git diff --git a/actions/twitterauthorization.php b/actions/twitterauthorization.php index cf27d69cf1..630ac426fd 100644 --- a/actions/twitterauthorization.php +++ b/actions/twitterauthorization.php @@ -1,6 +1,6 @@ . * - * @category Twitter - * @package Laconica - * @author Zach Copely - * @copyright 2009 Control Yourself, Inc. + * @category TwitterauthorizationAction + * @package StatusNet + * @author Zach Copely + * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -/** - * Class for doing OAuth authentication against Twitter - * - * Peforms the OAuth "dance" between Laconica and Twitter -- requests a token, - * authorizes it, and exchanges it for an access token. It also creates a link - * (Foreign_link) between the Laconica user and Twitter user and stores the - * access token and secret in the link. - * - * @category Twitter - * @package Laconica - * @author Zach Copley - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - * - */ class TwitterauthorizationAction extends Action { - /** - * Initialize class members. Looks for 'oauth_token' parameter. - * - * @param array $args misc. arguments - * - * @return boolean true - */ function prepare($args) { parent::prepare($args); @@ -114,12 +92,13 @@ class TwitterauthorizationAction extends Action // Get a new request token and authorize it $client = new TwitterOAuthClient(); - $req_tok = $client->getRequestToken(); + $req_tok = + $client->getRequestToken(TwitterOAuthClient::$requestTokenURL); // Sock the request token away in the session temporarily $_SESSION['twitter_request_token'] = $req_tok->key; - $_SESSION['twitter_request_token_secret'] = $req_tok->key; + $_SESSION['twitter_request_token_secret'] = $req_tok->secret; $auth_link = $client->getAuthorizeLink($req_tok); @@ -155,12 +134,12 @@ class TwitterauthorizationAction extends Action // Exchange the request token for an access token - $atok = $client->getAccessToken(); + $atok = $client->getAccessToken(TwitterOAuthClient::$accessTokenURL); // Test the access token and get the user's Twitter info $client = new TwitterOAuthClient($atok->key, $atok->secret); - $twitter_user = $client->verify_credentials(); + $twitter_user = $client->verifyCredentials(); } catch (OAuthClientException $e) { $msg = sprintf('OAuth client cURL error - code: %1$s, msg: %2$s', @@ -198,8 +177,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