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