Abraham's Twitteroauth Wrong Tokens?


Hey everyone,

I have a question regarding twitteroauth. I am successfully authenticating and geting oauth_token and oauth_token_secret but they do not work in my queries.

This is my authentication code and it is pretty standard.

	$twitteroauth = new TwitterOAuth('xxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');  
	$request_token = $twitteroauth->getRequestToken('http://www.somesite.com');  
	$_SESSION['oauth_token'] = $request_token['oauth_token'];  
	$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
	$_SESSION['action_stored'] = 'profile';
	 $url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']); 
		header('Location: '. $url); 

And this is an example that fails. The two tokens are wrong and if I pass the application’s preset (as found in the app settings), it works fine.

	$connection = new TwitterOAuth('xxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
	$content = $connection->get('account/verify_credentials');
            echo $content->name;

Can anyone spot an issue as I am baffled. I must be missing a step. There is no session issue or anything like that. I noticed that the preset oauth-token is different and begins with the user id. For example:



It looks like you are missing step 4-7 https://github.com/abraham/twitteroauth/blob/master/DOCUMENTATION

You only perform steps 1-7 when you don’t know who the users is. Once you know who they are and have an access_token you only perform steps 8 and nine for authenticated API requests.


Hello, thanks for the reply. I figured it out that I need to exchange the request token for an access one. It works great.


hey i am also getting same problem…can you please tell me how you solve that problem and my oauth token is like

1432259040-o0neah3pkiQHKQmCZWpKefqdbkfgjLAq0yO4dvk and its not working for post tweet to user account


I’m a new twitter application developer. I’m developing an application that get oauth and then store the oauth_token and oauth_secret_token to database. I know the way to get these token if we using session and Oauth. But I don’t know how can I get these token without session. I can get the oauth_verifier by read it in header that return after I make request. Is there anyway to make request and get the response (includes these tokens) from request or read in header?

Thanks very much!


i am using Abraham Williams’s twitteroauth.php and i am getting twiter oauth_token,oauth_secret…that i stored in session …and got oauth verifier in link and i got that with request method …now i want to get user access_token and aceess_token_secret for a particular user and my application … when i use getAccessToken($_REQUEST[‘oauth_verifier’]);
it gives error undifiend oauth_token and oauth_token secret in line no .114.
which is
$this->token = new OAuthConsumer($token[‘oauth_token’], $token[‘oauth_token_secret’]);
this is my code…can anyone help me…?

<?php session_start(); require("../../twitteroauth.php"); require_once '../src/twitter.class.php'; // ENTER HERE YOUR CREDENTIALS (see readme.txt) $consumerKey = "xxxxxxxxxxxxxxxxx"; $consumerSecret = "xxxxxxxxxxxxxxxxxxxxxx"; $OAuthToken = $_SESSION['oauth_token']; $OAuthSecret = $_SESSION['oauth_token_secret']; $_REQUEST['oauth_verifier']; $connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken,$accessTokenSecret); $oauth_verifier = $connection->getAccessToken($_REQUEST['oauth_verifier']); ?>


Thanks, you give link to 404 page.


Conectar a mi cuenta de plugger