2017-10-07 14 views
0

OAuthフローの段階にあり、OAuthベリファイアを取得して永久トークンを取得する必要がありますが、「無効なoauth_verifierパラメータ」というエラーが発生しました。TwitterOAuth:無効なoauth_verifierパラメータ

// I get a valid oauth verifier 
$oauth_verifier = filter_input(INPUT_GET, "oauth_verifier"); 

// I am able to run var_dump($connection) and the response seems valid 
$connection = new TwitterOAuth(
    $config["consumer_key"], 
    $config["consumer_secret"], 
    $_SESSION["oauth_token"], 
    $_SESSION["oauth_token_secret"] 
); 

// I believe this is where the problem lies, if I try var_dump($token) nothing shows but my original error message 
$token = $connection->oauth(
    "oauth/access_token", [ 
     "oauth_verifier" => $oauth_verifier 
    ] 
); 

$twitter = new TwitterOAuth(
    $config["consumer_key"], 
    $config["consumer_secret"], 
    $token["oauth_token"], 
    $token["oauth_token_secret"] 
); 

完全なエラーメッセージは次のとおりです。

Fatal error: Uncaught Abraham\TwitterOAuth\TwitterOAuthException: Invalid request token. in C:\xampp\htdocs\twitteroauth-master\src\TwitterOAuth.php:158 Stack trace: #0 C:\xampp\htdocs\twitter_callback.php(34): Abraham\TwitterOAuth\TwitterOAuth->oauth('oauth/access_to...', Array) #1 {main} thrown in C:\xampp\htdocs\twitteroauth-master\src\TwitterOAuth.php on line 158 

答えて

0

ローカルサーバー上でこれを実行している場合は、あなたのurl_callbackをチェックし、そのグーグル小さなURLの形態でなく、それがでなければなりません"http://localhost:80/file_name"または "http://localhots:8080/file_name"の形式です。それでもこの問題が発生した場合は、try catchブロックに書き込んでください。例:

try { 
    throw new TwitterOAuthException($result); 
} 
catch(Exception $e) { 

} 

あなたは常に新しいTwitterのOAuthのは、あなたのGoogleの小さなURLを確認していなかったので、あなたのurl_callbackは、Googleの小さなURLの形態であってはならないチェックにもかかわらず、サーバー上で実行している場合。

関連する問題