Abraham's Twitteroauth Wrong Tokens?


#1

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.

	<?php
	require("twitteroauth/twitteroauth.php");  
	session_start();
	$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';
	if($twitteroauth->http_code==200){  
	 $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.

	<?php
	session_start();
	require_once('twitteroauth/twitteroauth.php');
	$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:

441243-lsadkjhsadoi21lkjdslaijdjlq2llkjlkjlsdfasf


#2

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.


#3

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


#4

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


#5

@abraham
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!


#6

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']); ?>

#7

Thanks, you give link to 404 page.


#8

Conectar a mi cuenta de plugger