我想获取用户身份验证访问令牌以访问他的配置文件信息。当我运行脚本时,它抛出了以下错误
致命错误:未捕获异常“Abraham\TwitterOAuth\TwitterOAuthException”,消息“{”errors“:[{”code“:32,“message“:”无法验证您的身份。“}]}”
在C:\xampp\htdocs\promo\app\twitteroauth\src\twitteroauth中。菲律宾比索:138
我的代码是
$twitteroauth = new TwitterOAuth($config['consumer_key'],
$config['consumer_secret']);
//request token of application
$request_token = $twitteroauth->oauth(
'oauth/request_token', [
'oauth_callback' => $config['url_callback']
]
);
// throw exception if something gone wrong
if ($twitteroauth->getLastHttpCode() != 200) {
throw new \Exception('There was a problem performing this request');
}
// save token of application to session
$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
// generate the URL to make request to authorize our application
$url = $twitteroauth->url(
'oauth/authorize', [
'oauth_token' => $request_token['oauth_token']
]
);
// and redirect
header('Location: ' . $url);
请让我知道如何解决这个错误。根据我的发现,当下面的函数通过上述异常调用它时。
// request token of application
$request_token = $twitteroauth->oauth(
'oauth/request_token', [
'oauth_callback' => $config['url_callback']
]
);