我正在尝试使用雅虎的api和php实现誓言。当我试图获得授权时,会加载一个雅虎页面,要求我登录以授予授权。这个页面有一些奇怪的字符,当我输入一个电子邮件地址并单击“下一步”时,它会给出一个关于超时的错误:
$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;
}