Setting up
1. Download the Google API from http://www.google.com/apis/ and then follow the instructions to acquire a search key.
2. Get the >NET SDK if you don’t have it already and don’t have VS.NET
3. You can use the packaged Google api web service proxy or generate your own proxy class using the wsdl.exe util that comes packaged with ASP.NET SDK.
4. Compile the proxy class using a command something like
vbc /t:library /out:Google.dll Google.vb /r:System.web.dll /r:System.web.Services.dll /r:System.data.dll /r:system.dll /r:System.xml.dll
Note that for this we renamed the generated proxy class file to Google.vb mostly for clarity.
5. Next copy the generated Google.dll into the bin folder of your web app.
6. Add an entry in Web.config to hold the google key you received — in ours we put it in the appsettings section of web.config and called the key googlekey. Alternatively, you can hard-code the key in the search page.
7. Write the search page - a sample of our code is shown in the next section
public void GoogleSearch() { com.google.api.GoogleSearchService objSearch = new com.google.api.GoogleSearchService(); // Invoke the search method com.google.api.GoogleSearchResult objResults = objSearch.doGoogleSearch("license-key-goes-here", "India", 0, 10, false, "", false, "", "", "" ); // Loop through result elements short shtCount; for (shtCount = 0; shtCount <= objResults.endIndex - 1; shtCount++) { MessageBox.Show(objResults.resultElements(shtCount).title + " - " + objResults.resultElements(shtCount).URL); } }