2012-08-26 90 views
0

我試圖使用OAuth雅虎API。我有Auth URL,但我的CURL沒有返回任何內容。有人能指出我做錯了什麼嗎?頁面未返回 - 捲曲PHP

我想在登錄屏幕(假設我尚未登錄)..

$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); 

THANK YOU

+0

是你的代碼一樣,或者你忘了'';'末的URL? –

+0

對不起,這是打錯了......但我使用的實際代碼有沒有語法錯誤......我已經更新了我的帖子... – Fox

回答

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); 
+0

不工作...我嘗試過了....但是雅虎確實給該錯誤頁面,如果是的oauth_token錯... – Fox

+0

編輯,你忘了一些參數。 –

+0

這個鏈接是正確的堂妹在粘貼的登錄/權限,它要求在瀏覽器中的鏈接。 – Fox