Alright, I am still trying to solve this problem. Below is my code. I’m using Abraham’s oauth library.
require(‘twitteroauth/twitteroauth.php’);
unset($_SESSION[‘test’]);
session_destroy();
session_unset();
session_start();
// The TwitterOAuth instance
$twitteroauth = new TwitterOAuth(‘consumer’, ‘consumer’);
// Requesting authentication tokens, the parameter is the URL we will be redirected to
$request_token = $twitteroauth->getRequestToken(‘http://exhilaraterockford.com/twitter_oauth’);
// Saving them into the session
$_SESSION[‘oauth_token’] = $request_token[‘oauth_token’];
$_SESSION[‘oauth_token_secret’] = $request_token[‘oauth_token_secret’];
// If everything goes well…
if($twitteroauth->http_code==200){
// Let’s generate the URL and redirect
$url = $twitteroauth->getAuthorizeURL($request_token[‘oauth_token’]);
header('Location: '. $url);
} else {
// It’s a bad idea to kill the script, but we’ve got to know when there’s an error.
die(‘Something wrong happened.’);
}
Above is the login script, which then redirects the user to Twitter. They login and are sent back to /twitter_oauth, which has this code:
<?php
require(‘login.php’);
require(“twitteroauth/twitteroauth.php”);
session_start();
mysql_select_db($db_database);
if(!empty($_SESSION[‘username’])){
// User is logged in, redirect
header(‘Location: /appreciate’);
}
if(!empty($_GET[‘oauth_verifier’]) && !empty($_SESSION[‘oauth_token’]) && !empty($_SESSION[‘oauth_token_secret’])){
// We’ve got everything we need
} else {
// Something’s missing, go back to square 1
header(‘Location: /twitter_login’);
}
// TwitterOAuth instance, with two new parameters we got in twitter_login.php
$twitteroauth = new TwitterOAuth(‘Consumer’, ‘Consumer’, $_SESSION[‘oauth_token’], $_SESSION[‘oauth_token_secret’]);
// Let’s request the access token
$access_token = $twitteroauth->getAccessToken($_GET[‘oauth_verifier’]);
// Save it in a session var
$_SESSION[‘access_token’] = $access_token;
// Let’s get the user’s info
$user_info = $twitteroauth->get(‘account/verify_credentials.json’);
?>
I am seeing a few things. The session is updating and getting a new signature and nonce. The token and verifier remain the same. When I run $user_info = $twitteroauth->get(‘account/verify_credentials.json’); I receive the following: “stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => Bad Authentication data [code] => 215 ) ) )”
Any help would be appreciated.