domenica 17 ottobre 2010

Google Toolbar API - Custom search buttons

We all know the power of Google Toolbar, what we should know is that this extension is API-based: "The Google Toolbar API lets webmasters create custom buttons for the Google Toolbar (version 4 and above) using XML. Buttons can navigate to and search a site, display an RSS feed in a menu, and change their icon dynamically. Users can add your custom buttons to their Toolbar by clicking on a link on your website or Google's Button Gallery."


Adding custom search button is very easy. Unfortunately, at this moment, the API isn't smart enough to always retrieve the right way to interrogate a search engine. Moreover some website hides the correct way to interact with the search engine. It means that we'll have to edit the button using the Advanced Editor. More precisely we have to edit the tag  <search></search>.


Let's make an example. Let's assume that we want to create a custom button to search this blog or, in general, a blog hosted by Blogspot:
  1. Right click on the search box on the right of the page and select "Generate Custom Search..." from the menu that appears
  2. Click on "Add" and then "OK" in the Custom Button installation dialogs
The button will not work because the  API has built up a wrong URL to interrogate the search engine.
Let's open up the advanced editor and we'll see a tag like this:

<search charset="utf-8">http://stefanobolli.blogspot.com/?search={query}</search>

The URL isn't correct, it should be http://stefanobolli.blogspot.com/search?q={query} or, in general, http://username.blogspot.com/search?q={query}.


Let's consider a more difficult case: Ubuntu Forums.
Usually this kind of Forums uses an URL formatted in this way:

Domain Method to search Search Options
http://ubuntuforums.org/ search.php?do=process&query={query} ie:&showposts=1
ie:&forumchoice[]=id

In this case, we must be logged in to search our terms.

Sometimes we can retrieve the correct URL from the address bar, otherwise we should understand what kind of portal we have to deal with (ie: Joomla).


Best regards