0

我正在学习如何从Twitter 开发人员链接 上使用 OAuth 验证请求的链接中使用 twitter 我正在使用给定的程序调试我的代码

将用户发送到授权部分有这样写

如果您正在使用回调流程,您的 oauth_callback 应该已经收到您的 oauth_token(与您发送的相同,您的“请求令牌”)和一个名为 oauth_verifier 的字段。下一步您将需要它。

这是我收到的回复:

oauth_token=8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc&oauth_verifier=pDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY

我的原始代码是

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

我没有超过具有oauth_verifier的 URL 。请告诉我从哪里看到/调试该网址??

4

1 回答 1

2

是您从 . 返回后的oauth_verifierURL 上的参数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

于 2011-01-16T02:47:11.770 回答