0

我正在尝试使用 oAuth Yahoo API。我有 Auth URL,但我的 CURL 没有返回任何内容。有人可以指出我做错了什么吗?

我想要登录屏幕(假设我还没有登录)..

$auth_url = 'https://api.login.yahoo.com/oauth/v2/request_auth?oauth_token=qj94ktv';         

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL,$auth_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false)        

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

谢谢你

4

1 回答 1

0

curl_exec($ch);没有传递给浏览器。此外,您在重定向时不会跟随位置,并且RETURNTRANSFER

您需要为其分配一个变量或只是转储它:

$auth_url = 'https://api.login.yahoo.com/oauth/v2/request_auth?oauth_token=qj94ktv';         
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL,$auth_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);       
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
// grab URL and pass it to the browser
echo curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
于 2012-08-26T01:07:51.800 回答