【问题标题】:Yahoo oauth2 - getting access token from codeYahoo oauth2 - 从代码中获取访问令牌
【发布时间】:2015-04-15 19:22:28
【问题描述】:

我正在尝试将我的应用程序与 Yahoo oauth2 登录集成。我没有使用任何外部库并按照https://developer.yahoo.com/oauth2/guide/中的说明进行操作

我生成了授权 URL,将用户重定向到 yahoo 的登录页面并获得了代码(完成了 Yahoo 指南中的步骤 1-3)。

现在我必须传递此代码并获取访问令牌。 (第四步:兑换Access Token授权码)

为此,我使用下面给出的代码

$fields_string = 'grant_type=authorization_code&redirect_uri='.$CALLBACK_URL.'&code='.$code;
$fieldCount=3;

$ch = curl_init();

$headers = array(Authorization: Basic '. base64_encode($CONSUMER_KEY.':'.$CONSUMER_SECRET),
    'Content-Type:x-www-form-urlencoded'
);

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, $fieldCount);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

curl_exec($ch);
result = curl_exec($ch);

但这不起作用,我没有得到雅虎的任何回应。任何帮助表示赞赏。谢谢。

【问题讨论】:

    标签: yahoo-api


    【解决方案1】:

    好的,解决了。调用类似于 https://github.com/saurabhsahni/php-yahoo-oauth2/blob/master/YahooOAuth2.class.php 中的 get_access_token 方法

    【讨论】:

      猜你喜欢
      • 2021-03-27
      • 1970-01-01
      • 2023-04-05
      • 2021-11-10
      • 2013-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-27
      相关资源
      最近更新 更多