0

I am having problem with the yahoo search API,sometimes it works and sometimes don't why I am getting problem with that

I am using this URL

http://api.search.yahoo.com/WebSearchService/rss/webSearch.xml?appid=yahoosearchwebrss&query=originurlextension%3Apdf+$search&adult_ok=1&start=$start

The code is given below:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">          
 
<?
$search = $_GET["search"];
$replace = " "; $with = "+";
$search = str_replace($replace, $with, $search);
 
if ($rs = $rss->get("http://api.search.yahoo.com/WebSearchService/rss/webSearch.xml?appid=yahoosearchwebrss&query=originurlextension%3Apdf+$search&adult_ok=1&start=$start")) 
{
 
}
 
// Go through the list powered by the search engine listed and get the data from each <item>
$colorCount="0";
 
   foreach($rs['items'] as $item) 
	{ 
 
	// Get the title of result
 
	   $title = $item['title'];
 
	// Get the description of the result
 
	   $description = $item['description'];
 
	// Get the link eg amazon.com
 
	   $urllink = $item['guid'];
 
if($colorCount%2==0)
{
$color = ROW1_COLOR;
}
else
{
$color = ROW2_COLOR;
}
 
include "resulttemplate.php";
$colorCount++;
 echo "\n"; 
 
}  
?>

Sometimes it gives results and sometimes don't...I get this error usually

Warning: Invalid argument supplied for foreach() in /home4/thesisth/public_html/pdfsearchmachine/classes/rss.php on line 14

Can anyone help..

3
Contributors
19
Replies
20
Views
6 Years
Discussion Span
Last Post by amit.hak50
0

Previously i have explained you reason for foreach error.
Also as i said your given API string is not working for me.

Here is API link i found for yahoo.
http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=yahoo

You can find more parameter options here.
http://developer.yahoo.com/search/web/V1/webSearch.html

Thanks a lot for your reply

So which String I need to use instead of http://api.search.yahoo.com/WebSearchService/rss/webSearch.xml?appid=yahoosearchwebrss&query=originurlextension%3Apdf+$search&adult_ok=1&start=$start

can you please tell ..I am confused ,It makes my application hell

0

Try this

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">    
<?

$search = urlencode($_GET["search"]);
 
if ($rs = $rss->get("http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=$search")) 
{  
	// Go through the list powered by the search engine listed and get the data from each <item>
	$colorCount="0"; 
	if(count($rs['items']) >0)
	{
		foreach($rs['items'] as $item) 
		{  
			// Get the title of result 
			$title = $item['title']; 
			// Get the description of the result 
			$description = $item['description']; 
			// Get the link eg amazon.com 
			$urllink = $item['guid']; 
			if($colorCount%2==0)
			{
				$color = ROW1_COLOR;
			}
			else
			{
				$color = ROW2_COLOR;
			}		
			include "resulttemplate.php";
			$colorCount++;
			echo "\n"; 
	 
		}  
	}
	else
	{
		echo "No items in result";exit;
	}
}
else
{
	echo "No result in RSS parser";exit;
}
?>

M considering you have proper RSS reader class.

0

Oh ,Thanks sister,you really great ,Hoping to get the solution done

0

Actually these websites might have changed underlined architecture of the api and hence it is creating such problem....try to search correct and reliable source of api.....

0

Hey it is working on this link now.
What was issue?

I did not change anything ,I don't know wht was the issue,may be the API was down or yahoo limits the number of searches per IP like around 5000 ,i don't know ,same happened yesterday ,it was not working and than working than stops today and now again working ,I don't know what will be next ,I think i must move to bing API as it allows unlimited number of API calls ,yahoo charges if you exceed the number above 5000..do you suggest anything

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.