August 07, 2008
by Marco Vitanza
BOSS (Build your Own Search Service) is Yahoo's new open search platform. Using the BOSS API, developers have access to Yahoo's entire search index to create custom searches, mashups, and more. Read more about it here.
A practical (and simple) use for BOSS is to build a custom search page so that users can search your website. I wrote a simple search page to do this using PHP with the CURL extension.
Let's take a look at the steps needed to execute a simple site search with BOSS and PHP:
- Get a query from a user (web form).
- Build the BOSS query URL with your Yahoo AppID and other parameters.
- Submit the query to BOSS (using a CURL GET request)
- Receive the XML (or JSON) data from BOSS.
- Parse the XML and display the results.
Try out the search here.
View the code here (formatted).
Download the code here (text).
UPDATED: Added support for multiple result pages.

Comment by Flame on September 01, 2008 at 07:40am
That's nice a simple, thanks a lot for the code.

Comment by Sudhanshu on November 11, 2008 at 11:50am
Pretty cool. Terrific job

Comment by Robert on January 20, 2009 at 10:29am
Hi,
Do you by chance also have a code example for image and or news search? I also have a PHP script available, but also only for regular search: http://www.subscribetomyblog.com/spotlight/yahoo-boss-php-code-examples-are-hard-to-come-by

Comment by Robert on January 20, 2009 at 10:46am
Hi I also have a search engine based on Yahoo Boss. You can download the PHP script from my blog if you want.: http://www.subscribetomyblog.com/spotlight/yahoo-boss-php-code-examples-are-hard-to-come-by. Do you by the way have a PHP script for image search with Yahoo Boss?

Comment by desbest on January 31, 2009 at 12:59am
I prefer BOSS's JSON and XML output format than that Google Web Search API coz they got rid of the xml output feature.
I know JQuery, xml, and php, but I've never worked with xml before. Thanks to you I can use BOSS so easily and have something to learn xml from. Thanks alot. You're awesome!

Comment by Nick on February 19, 2009 at 09:27am
Thank you very much for the code.
I am no XML or PHP expert and i'm trying to get your example work so I can adapt it for a sirte of mine. I have got my own app code but whatever I search for I get 0 results. I want this to be an external search - would I remove '&site=' from the query ?