Google.cfc v0.3

Why

It took me a few hours to make the Google API work with Cold Fusion. The results of the search API are a complex java object, so there seemed a need for translating this to something more coldfusion native.

Usage

<cfinvoke component="lab.cf.google.google" method="search" returnvariable="googleResults" >
  <cfinvokeargument name="q" value="uzilla"/>
  <cfinvokeargument name="start" value=1/>
  <cfinvokeargument name="maxResults" value="10"
  <cfinvokeargument name="key" value="...">
</cfinvoke>

The search method returns an array of structures with the following keys:

CACHEDSIZE
HOSTNAME
SNIPPET
SUMMARY
TITLE
URL

Change Notes

  • v0.3: Added ability to query for more than just 10 records. Note, for every 10 retrieved, you will use one of your 1000 daily allotted queries.

Source

google_cfc.zip

License

google.cfc is licensed under the Mozilla Public License. If you improve it, you are obligated to share your enhancements.

Future Work

Additional development might support more methods of the google api, optionally return a query instead of a struct. What else? Built-in caching?

Feedback to andyed(at)surfmind.com.

Sample Query: Top Twenty Results for "cold fusion blog" (with filter on)

Error Occurred While Processing Request The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.


The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request

Could not generate stub objects for web service invocation.

Name: http://api.google.com/GoogleSearch.wsdl. WSDL: http://api.google.com/GoogleSearch.wsdl. org.xml.sax.SAXException: Fatal Error: URI=null Line=20: The element type "meta" must be terminated by the matching end-tag "". It is recommended that you use a web browser to retrieve and examine the requested WSDL document for correctness. If the requested WSDL document can't be retrieved or it is dynamically generated, it is likely that the target web service has programming errors.
 
Resources:
  • Enable Robust Exception Information to provide greater detail about the source of errors. In the Administrator, click Debugging & Logging > Debugging Settings, and select the Robust Exception Information option.
  • Check the ColdFusion documentation to verify that you are using the correct syntax.
  • Search the Knowledge Base to find a solution to your problem.

Browser   CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
Remote Address   38.107.191.86
Referrer  
Date/Time   18-Mar-10 02:05 AM