Login with twitter showing error


#1

connect.php–>

echo " sign in with twitter ";

redirect.php–>

require_once(‘twitteroauth/twitteroauth.php’);

setcookie(“oauth_token”,“xxx”);
setcookie(“oauth_token_secret”, “xxx”);

$connection = new TwitterOAuth(‘UNfNzgWAfNXTScA9cIzvfYGyk’, ‘vJn6H1uFE7S3TRw517VzWkIDwIYszY3W7gAtfSaZwsmCX7HJ80’);
$request_token = $connection->getRequestToken(‘http://direct.metricglobal.com/twitter/callback.php’);

$oauth_token = $token = $request_token[‘oauth_token’];
$oauth_token_secret = $request_token[‘oauth_token_secret’];
setcookie(“oauth_token”,$oauth_token);
setcookie(“oauth_token_secret”, $oauth_token_secret);

if( $_COOKIE[“oauth_token”] == “xxx” || $_COOKIE[“oauth_token_secret”] == “xxx” )
{
exit();

}
else
{

	switch ($connection->http_code) 
	{
		case 200:
			$url = $connection->getAuthorizeURL($token);
			header('Location: ' . $url);
			 
		    break;
		default:
		    echo "Coonection with twitter Failed error no -- ".$connection->http_code;
	    	exit();
	}

}

?>

callback.php–>

require_once(‘twitteroauth/twitteroauth.php’);

$oauth_token = $_COOKIE[“oauth_token”];
$oauth_token_secret = $_COOKIE[“oauth_token_secret”];
$oauth_verifier = $_REQUEST[‘oauth_verifier’];

// $connection = new TwitterOAuth(‘UNfNzgWAfNXTScA9cIzvfYGyk’, ‘vJn6H1uFE7S3TRw517VzWkIDwIYszY3W7gAtfSaZwsmCX7HJ80’, $oauth_token, $oauth_token_secret);

$connection = new TwitterOAuth(‘UNfNzgWAfNXTScA9cIzvfYGyk’, ‘vJn6H1uFE7S3TRw517VzWkIDwIYszY3W7gAtfSaZwsmCX7HJ80’, $oauth_token);
$access_token = $connection->getRequestToken($_REQUEST[‘oauth_verifier’]);

if( $connection->http_code == 200 )
{

 $content = $connection->get('account/verify_credentials');

 echo "<pre>", print_r($content, true)  , "</pre>";

}
else
{
echo "connection error code is ".$connection->http_code;

}

It prints output like–>

stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[message] => Invalid or expired token
[code] => 89
)

    )

)

Will you please let me know were i am going wrong and why its not printing the info about logged in user?
I tank you all in advance.