【问题标题】:Always get token_rejected error when trying to call yahoo contacts API尝试调用 yahoo 联系人 API 时总是出现 token_rejected 错误
【发布时间】:2013-11-22 14:39:29
【问题描述】:

根据雅虎文档,我经历了以下步骤:

  1. 接收请求令牌
  2. 将用户重定向到 yahoo 身份验证页面
  3. 在回调页面使用 GET 参数中的令牌获取 oauth_token
  4. 接收 oauth_token 并尝试通过以下 url 调用联系人 api 以获取具有 GET 请求的联系人列表:

    http://social.yahooapis.com/v1/user/'.$xoauth_yahoo_guid。 '/contacts?format=json&oauth_consumer_key='._YH_APP_CK. '&oauth_signature_method=PLAINTEXT&oauth_nonce=noncedata&oauth_version=1.0'。 '&oauth_signature='._YH_APP_SK.'%26'.$_SESSION['yahoo_token_secret']。 '&oauth_token='.$oauth_token. '&oauth_timestamp='.date_timestamp_get(date_create());

在哪里

$xoauth_yahoo_guid // user id
_YH_APP_CK // consumer key
_YH_APP_SK // consumer secret key
$_SESSION['yahoo_token_secret'] // secret token that was received from yahoo

我使用PLAINTEXT 作为oauth_signature_method 并连接密钥和秘密令牌来设置签名,如文档中所述,但我仍然收到token_rejected 错误,有人可以帮我找出原因吗?谢谢。

【问题讨论】:

  • 你有 session_start();在你的 php 脚本的开头?
  • 是的,会话正常工作,$_SESSION['yahoo_token_secret'] 具有正确的值

标签: php yahoo-api


【解决方案1】:

我发现oauth_signature_method=PLAINTEXT 不能用于http:// 请求。所以在这种情况下应该使用oauth_signature_method=HMAC-SHA1。 以下代码可用于使用 HMAC-SHA1 方法创建 oauth_signature: https://github.com/joechung/oauth_yahoo/blob/master/getacctok.php

【讨论】:

    猜你喜欢
    • 2013-12-27
    • 2019-10-19
    • 2012-06-12
    • 1970-01-01
    • 1970-01-01
    • 2020-01-14
    • 1970-01-01
    • 2013-06-21
    • 1970-01-01
    相关资源
    最近更新 更多