Twitter LogIn不起作用。无效和过期的令牌

时间:2015-05-26 09:20:56

标签: php twitter twitter-oauth

我遵循此代码,并使用了库http://hayageek.com/login-with-twitter/

登录有效,但我认为程序生成的oauth令牌很糟糕。这是我的问题,我不知道如何解决:

$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET);

$request_token = $connection->getRequestToken($OAUTH_CALLBACK); //get Request Token

if( $request_token)
{
    echo print_r($request_token);
    $token = $request_token['oauth_token'];

    $_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);
            //redirect to Twitter .
            header('Location: ' . $url); 
            break;
        default:
            echo "Coonection with twitter Failed";
            break;
    }

}
else //error receiving request token
{
    echo "Error Receiving Request Token";
}


 and after log in the page the callback page do this:

    $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
    /
     $content = $connection->get ( "account/verify_credentials" );

现在我获得了#34;无效且已过期的令牌"。有人可以帮帮我吗?

0 个答案:

没有答案