CFMX CFC wrapper for Google Search API
Quick start guide
- Download the cfc (Yes it is buried way down in the folder structure)
- Put it in the a web accessible folder
- Get a Google Licence key from the Google API site
- Put your licence key in the googleSearch.cfm file
- View the googleSearch.cfm - happy hacking
Do a search:
<cfset search = oGoogle.doGoogleSearch(key=googleKey,q=q)>
<cfif search.status>
<cfdump var="#search#">
<cfelse>
Remote call failed
</cfif>
Get a spelling suggestion:
<cfset spell = oGoogle.doSpellingSuggestion(key=googleKey,phrase=spellPhrase)>
<cfif spell.status>
<cfdump var="#spell#">
<cfelse>
Remote call failed
</cfif>
Get a page cache (or the last time google cached the page)
<cfset cache = oGoogle.doGetCachedPage(key=googleKey,url=cachePage)>
<cfif cache.status>
<cfdump var="#cache#">
<cfoutput>#cache.content#</cfoutput>
<cfelse>
Remote call failed
</cfif>
Isn't this just another layer to slow it down?
Yes and No. Yes it is another layer, but it will not slow it down noticeably. The advantage it gives is that you are calling local methods in your application not remote methods (the cfc handles the remote stuff and can do appropriate error handling). It should be noted that you should be doing something similar for all webservice calls you are doing from CF - so that you can elegantly handle errors if the webservice is not available.




