页面未被返回 - CURL PHP

时间:2012-08-26 01:00:17

标签: php api curl oauth-2.0 yahoo-api

我正在尝试使用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);

谢谢你

1 个答案:

答案 0 :(得分: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);