我收到以下错误:
Error processing your OAuth request: Invalid oauth_verifier parameter
我一直在阅读问题是在库TwitterOAuth by Abraham
中我们需要在标题中设置oauth_verifier而不是正文。
我不知道该怎么做。
这是我的代码:
// twitterlogin.php
session_start();
$twitterKey = 'xxx';
$twitterSecret = 'xxx';
$callback = "https://xxx/socialmedia/twittercallback.php";
require_once("/xxx/twitteroauth/vendor/autoload.php");
use Abraham\TwitterOAuth\TwitterOAuth;
$twitter = new TwitterOAuth($twitterKey,$twitterSecret);
$result = $twitter->oauth('oauth/request_token', ['oauth_callback' => $callback]);
$_SESSION['oauth_token'] = $result['oauth_token'];
$_SESSION['oauth_token_secret'] = $result['oauth_token_secret'];
$url = $twitter->url('oauth/authorize', array('oauth_token' => $result['oauth_token']));
header("Location: $url");
// twittercallback.php
session_start();
require_once("/xxx/api");
$twitterKey = 'xxx';
$twitterSecret = 'xxx';
require_once("/xxx/twitteroauth/vendor/autoload.php");
$twitter = new \Abraham\TwitterOAuth\TwitterOAuth($twitterKey,$twitterSecret,$_SESSION['oauth_token'],$_SESSION['oauth_token_secret']);
try {
$access_token = $twitter->oauth("oauth/access_token", ["oauth_verifier" => $_GET['oauth_verifier']]);
$_SESSION['access_token'] = $access_token;
} catch(\Exception $e){
print "<pre>".print_r($e,true)."</pre>";
}
var_dump($access_token);
如何在标题中设置oauth_verifier?
谢谢!