complete guide to google ajax search api

7
Complete Guide to Google Ajax Search API Explained by Rohit Ghatol [email protected]

Upload: rohit-ghatol

Post on 13-Jan-2015

1.287 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Complete Guide to Google Ajax Search API

Complete Guide to Google Ajax Search API

Explained by Rohit [email protected]

Page 2: Complete Guide to Google Ajax Search API

Why use Google Ajax Search API?

• Allow user to search on your site• Allow user to get categorized search results• Allow the search results to be restricted to a domian• Help user with recommended search key words• Show Video Bar, Book Bar, Blog bar and News Bar

Page 3: Complete Guide to Google Ajax Search API

Getting Started

1. Get a Google Ajax Search API Key for your domain2. Code for Categoried search results3. Code for chaning look and feel and position of search

results4. Code for restricting Search results to a Domain5. Code for adding Map Search, Video Search6. How to use wizards for Book/Blog/Video/News Bar7. How to setup a Custom Search Engine8. Using the Custom Search Engine to refine search results

Page 4: Complete Guide to Google Ajax Search API

Get the Key from this Page

Page 5: Complete Guide to Google Ajax Search API

GSearchControl

GwebSearch

div with id “searchcontrol”

Code for Categorized Search Result

Page 6: Complete Guide to Google Ajax Search API

Code for Categorized Search Result

<html><head><script src="../../api?file=uds.js&amp;v=1.0" type="text/javascript"></script><script type="text/javascript">//<![CDATA[...................... (see next slide)//]]></script></head><body><div id="searchcontrol">Loading</div></body></html>

Page 7: Complete Guide to Google Ajax Search API

Code for Categorized Search Result<script type="text/javascript">//<![CDATA[function OnLoad() {// Create a search controlvar searchControl = new GSearchControl();// Add in a full set of searchersvar localSearch = new GlocalSearch();searchControl.addSearcher(localSearch);searchControl.addSearcher(new GwebSearch());searchControl.addSearcher(new GvideoSearch());searchControl.addSearcher(new GblogSearch());searchControl.addSearcher(new GnewsSearch());searchControl.addSearcher(new GimageSearch());searchControl.addSearcher(new GbookSearch());// Set the Local Search center pointlocalSearch.setCenterPoint("New York, NY");// tell the searcher to draw itself and tell it where to attachsearchControl.draw(document.getElementById("searchcontrol"));// execute an inital searchsearchControl.execute("VW GTI");}GSearch.setOnLoadCallback(OnLoad);//]]></script>