在亚伯拉罕Twitteroauth课程中需要一些帮助
-
10-10-2019 - |
题
我正在学习如何使用Twitter Twitter开发人员链接关于使用OAuth页面进行认证请求,我正在用给定的过程调试我的代码
上 向用户发送授权 有文章
如果您使用的是回调流,则您的oauth_callback应该收到您的oauth_token(与您发送的相同,“请求令牌”)和一个名为oauth_verifier的字段。下一步您将需要。
这是我收到的答复:
oauth_token = 8ldizyxqevrfzxfozh5tawj6vzjyulqpl0wueytwc&oauth_verifier = pdng57prohapmbhv25rnf75lv75lvrd6jdsni1ajjjidyoty
我的原始代码是
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');
/* Build TwitterOAuth object with client credentials. */
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
/* Get temporary credentials. */
$request_token = $connection->getRequestToken(OAUTH_CALLBACK);
/* Save temporary credentials to session. */
$_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
/* If last connection failed don't display authorization link. */
switch ($connection->http_code) {
case 200:
/* Build authorize URL and redirect user to Twitter. */
echo "<br/>Authorize URL:".$url = $connection->getAuthorizeURL($token);
//header('Location: ' . $url);
break;
default:
/* Show notification if something went wrong. */
echo 'Could not connect to Twitter. Refresh the page or try again later.';
}
我得到授权的URL:
https://twitter.com/oauth/authenticate?oauth_token=BHqbrTjsPcyvaAsfDwfU149aAcZjtw45nhLBeG1c
我没有超越URL oauth_verifier. 。请告诉我从哪里看到/调试该URL?
解决方案
这 oauth_verifier
是您从您返回之后的URL上的paramater https://twitter.com/oauth/authenticate?oauth_token=xyz
. 。因此,如果您的callback_url是 http://example.com/oauth/complete
单击允许在Twitter.com上后,您应该在 http://example.com/oauth/complete?oauth_token=xyz&oauth_verifier=xyz
不隶属于 StackOverflow