Yahoo Oauth重定向错误

时间:2019-02-19 22:43:58

标签: php oauth-2.0 yahoo-api

我正在尝试使用Yahoo的api和php实现誓言。当我尝试获得授权时,会加载Yahoo页面,要求我登录以提供授权。该页面上有一些奇怪的字符,当我输入电子邮件地址并单击“下一步”时,它给出了有关超时的错误: image of login page

我没有做很多网络编程,也弄不清楚我在做什么错。这是代码:

$client_id = "dj0y........";
$client_secret = "23f......";
$redirect_uri = "http://www.example.com/yweather.html";
getSslPage("https://api.login.yahoo.com/oauth2/request_auth?client_id=$client_id&redirect_uri=$redirect_uri&response_type=code&language=en-us");

public function getSslPage($url, $optional_headers=null) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $headers = array("User-Agent: ISCADG/v1.0 (http://www.example.com; john@example.com)");
    if ($optional_headers) {
        $headers = array_merge($headers, $optional_headers);
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

0 个答案:

没有答案