PW Forum / Problem with Yahoo API

You are not logged in.


#1 2007-01-11 11:03:19

madsadman
New member
Registered: 2006-12-08
Posts: 2

Problem with Yahoo API

Hi,

I tested my application on a different server (a test server) and when I migrated it to the production, all the APIs based on REST were working fine EXCEPT for Yahoo APIs.

All the Yahoo APIs are returning problems like "function.fopen]: failed to open stream: No route to host ".

Can you please help me out in this regard.

Himanshu

Offline

 

#2 2007-01-15 13:07:15

gotfoo
New member
Registered: 2006-08-24
Posts: 4
Website

Re: Problem with Yahoo API

Try it using curl like this:

$keyword = $_GET['keyword'];
$base = "http://api.search.yahoo.com/WebSearchService/V1/webSearch";
$params = array("appid"=>"YahooDemo", "query"=>$keyword,"results"=>"20");
$url  = $base.'?'.http_build_query($params);
$c = curl_init($url);
curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
$response = curl_exec($c);
curl_close($c);
$xml = simplexml_load_string($response);
$html .= "<h2>Yahoo! Search: ".$keyword."</h2>";
foreach($xml->Result as $result) {
    $html .= "<p>\n";
    $html .= "<a href='".$result->ClickUrl."' title='".$result->DisplayUrl."'>".$result->Title."</a>";
    $html .= "<br>";
    $html .= $result->Summary;
    $html .= "<br>";
    $html .= "</p>\n";
}
echo $html;

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

Follow the PW team on Twitter

ProgrammableWeb
APIs, mashups and code. Because the world's your programmable oyster.

John Musser
Founder, ProgrammableWeb

Adam DuVander
Executive Editor, ProgrammableWeb. Author, Map Scripting 101. Lover, APIs.