Tutorial: Create a Yahoo BOSS powered Site Search Engine

Published in: google custom search - yahoo

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 ’’.$result->title.’
’; }

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

Published in: google custom search - yahoo

Looking for something? Find here!

Meet the Author

Web Geek, Tech Columnist
Amit Agarwal

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

Get in touch