2014-01-20 50 views
-6

我試圖在雅虎curl服務上測試php_curl,但我從雅虎收到錯誤。PHP cURL:從yahoo/google api檢索搜索數據?

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

// set URL and other appropriate options 
// http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=persimmon&results=10 
curl_setopt_array(
    $handle, 
    array(
     CURLOPT_URL => 'http://search.yahooapis.com/WebSearchService/V1/webSearch', 
     CURLOPT_POST => true, 
     CURLOPT_POSTFIELDS => 'appid=YahooDemo&query=test&results=10', 
     CURLOPT_RETURNTRANSFER => true 
    ) 
); 

$response = curl_exec($handle); 
curl_close($handle); 

$xml = new SimpleXMLElement($response); 

foreach($xml->Result as $x) { 
    echo $x->Title.'<br/>'; 
} 

echo '<pre>'; 
print_r($xml); 

結果:

SimpleXMLElement Object 
(
    [Message] => The service has been shut down. For further details, please see the Deprecated Services blog post http://developer.yahoo.com/blogs/ydn/posts/2010/08/api_updates_and_changes 
) 

任何例子來從雅虎,因爲該服務搜索數據已被棄用?它似乎需要從他們的BOSS API支付一些款項。

googel api怎麼樣 - 如果我想要從Google返回搜索數據,我該去哪裏?

回答

6

有什麼想法爲什麼?

您是否閱讀了消息?

該服務已關閉。有關詳細信息,請參閱棄用服務的博客文章http://developer.yahoo.com/blogs/ydn/posts/2010/08/api_updates_and_changes

該URL說:

其他非BOSS搜索API,例如網頁搜索,圖片搜索,新聞搜索,相關的建議和網站資源管理器API將關閉,YQL無需進一步支持。

所以......

這樣,我怎麼能得到驗證,以從Twitter獲取數據/狀態?

https://dev.twitter.com/docs/auth