954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Yahoo Search API

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..

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 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

vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 

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

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 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.

vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 

Thanks again ,I want to refine the search to get only pdf results,is this URL give only PDF results

http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=$search


,I am using that on http://www.pdfsearchmachine.com

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 
vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 

if you can go to the website http://www.pdfsearchmachine.com ,I did as you say but again same problem,It downs my search engine ,:( ,I am no where

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

Place this code and upload it on live.
I want to see result on live.

$search = urlencode($_GET["search"]);
$rs = $rss->get("http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=$search");
echo '$rs IS ==>'; 
print_r($rs);
exit;
vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 

I wonder the other website http://pdf-download-engine.com uses same query and it works

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 
I wonder the other website http://pdf-download-engine.com uses same query and it works

You have to debug it and find the reason.
There is no rocket science.
So i told you to upload my last code on live so that i can debug.

vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 

Hope you are using proper Application id.
It is different for individual sites.
http://developer.yahoo.com/faq/#appid

vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 

ok,bro ,Thanks doing that

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

Hey.. m not bro.. m sis :)
ok,bro ,Thanks doing that

vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 

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

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

can you please add me on gmail : [email]amit.hak50@gmail.com[/email],if you think i would not disturb you

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

Nothing is printed ,I did ,It says some parse error :(

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

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


look the site it is working now ,I don't know why ,I am using above one URL,no changes i made ,I wonder

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 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.....

tomato.pgn
Posting Whiz in Training
262 posts since Mar 2011
Reputation Points: 4
Solved Threads: 32
 
I am using that on http://www.pdfsearchmachine.com


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

vibhaJ
Posting Shark
931 posts since Apr 2010
Reputation Points: 161
Solved Threads: 183
 
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

amit.hak50
Junior Poster in Training
65 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: