Tutorial: Create a Yahoo BOSS powered Site Search Engine

yahoo-boss While it is extremely easy to implement Google Custom Search in your site, the Google service is kind of limited in the sense that you little control over the search results that display on your site. You can neither reorder search results nor can you include additional information in the search pages.

Enter Yahoo BOSS, a service overcomes most limitations of Google Custom Search. It lets you display search results in the format you like, or add image thumbnails to your results page (similar to Cuil) or you can even hide certain web pages from appearing in search results.

If you like to experiment with Yahoo! Boss for your own site search, here’s a quick tutorial to help you get started. Just apply for an AppID and then replace the appropriate values in the following PHP file.

// Get the Yahoo BOSS AppID from https://developer.yahoo.com/wsregapp/
define ('APP_ID', 'YOUR_APPID_HERE');

// Restrict site search to your own domain - replace labnol.org
$query = $\_GET ['q'] . '+site:labnol.org';

// Get search results from Yahoo BOSS as an XML\*
$API = 'http://boss.yahooapis.com/ysearch/web/v1/';
$request = $API . $query .'?format=xml&appid='. APP_ID;

$ch = curl_init($request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$xml = simplexml_load_string (curl_e xec($ch));

// Display search results - Title, Date and URL.
foreach ($xml->resultset_web->result as $result) {
 print '<a href="'.$result->clickurl.'">'.$result->title.'</a><br />';
}

You can directly use file_get_contents() instead of the cURL library but some web hosts (like Dreamhost) do not allow fopen on external files.

Tweak Your Search Results

These results (like Gmail, Google Chrome, India) are presented in a plain vanilla interface but you could easily wrap them in a WordPress plug-in that displays addition information next to search results like associated thumbnail images, tags, number of comments, etc. To see all this in action, check out the gmail search on TechCrunch.

Ads in Yahoo! Boss

Yahoo! has promised that they’ll brings ads to Yahoo! Boss so you will be able to monetize site search in the same manner as AdSense for Search. It may however be limited to US residents only since you require a valid SSN to gain entry into the Yahoo Ad Network.

Update: Make sure that you use the ClickURL value for the HREF value in your search results and not the direct URL as this is a requirement according to their BOSS API terms of use.

Amit Agarwal

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

0

Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards in 2017.

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

Sign up for our email newsletter to stay up to date.

We will never send any spam emails. Promise.