August 07, 2008
Custom Search with Yahoo BOSS and PHP
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:

  1. Get a query from a user (web form).
  2. Build the BOSS query URL with your Yahoo AppID and other parameters.
  3. Submit the query to BOSS (using a CURL GET request)
  4. Receive the XML (or JSON) data from BOSS.
  5. 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

Post Comment

Name:
Comment:  
Security Code: Verification Code Five Digits