Using twitterOAuth for login scripts


I recently started working with twitteroauth login, which seems to be working in the examples but not when I amalgamate the redirect.php and callback.php
Based on the script below (which is integrated in a bit of log in script I’ve been working on) the second portion works fine (which is based on redirect.php), returning and oauth_token and oauth_verifier, but the first part (based on callback.php) isn’t even initiating it seems.

Any ideas/suggestions folks?

require_once('socialCodes.php');    //where I keep my app ID and Secret

if (isset($_GET['oauth_token'])) {	// we're being called back by Twitter
	$connection = new TwitterOAuth($twAppID, $twAppSec, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
	$connection->host = "";

	$access_token = $connection->getAccessToken($_GET['oauth_verifier']);

	$_SESSION['access_token'] = $access_token;


	if (200 == $connection->http_code) {
		$userAccessToken = $access_token['oauth_token'];
		$userSecretToken = $access_token['oauth_token_secret'];
		$userID = $access_token['user_id'];
		$userName = $access_token['screen_name'];

} else {
	$connection = new TwitterOAuth($twAppID, $twAppSec);
	$connection->host = "";
	$request_token = $connection->getRequestToken('myhomepage');

	$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
	$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
	switch ($connection->http_code) {
	  case 200:
	    $url = $connection->getAuthorizeURL($token);
	    header('Location: ' . $url); 
	  echo 'Could not connect to Twitter. Refresh the page or try again later.';


How do you know the first part doesn’t work? From the code here it looks like it should get an access_token, set some variables, and then do nothing.


My apologies, I forgot to close this discussion when I closed my StackOverflow discussion.
Turns out it was a caching issue, it worked the next day.