2014-01-20 51 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