CFGoogle - A ColdFusion Package For Interacting With Several Google APIs

Posted By : todd sharp Posted At : July 15, 2009 9:16 AM Posted In: Google, ColdFusion

8

I'm happy to announce that I've launched CFGoogle on RIAForge. This project is a set of ColdFusion Components built to interact with a number of Google APIs. The package contains a base CFC which provides basic authentication and session token retrieval. Other components in the package extend the base CFC to interact with individual Google services such as Docs and Analytics.

The base code and all inspiration for this project are taken (with permission from and many thanks) from the original work done by Raymond Camden to authenticate and work with the Google Docs API. The analytics component wraps some common dimensions into convenience methods for you. However, there are tons of different possible combinations of dimensions and metrics that you can pass to the Analytics API to get at your data. Have a look at the Analytics API if you feel need more data then I'm exposing with the convenience functions. The Google documentation is pretty decent, this page in particular should help you out with possible dimensions and metrics. If you want to roll your own query you can call the getAnalyticsData() method and pass it dimensions, metrics, filters, sorts, date ranges, etc. Most methods will return a struct - one key for the query, another for some metadata from the Google data feed. Play around with different combinations and see what you can get. Finally, here's a quick screencast if you're really bored and want to watch me demo the package:

Comments (8)

Coldfusion Nerd's Gravatar Very nice! I am pretty sure I will make great use of this package, so thanks for putting together.

If my projects ever die down, I will release a good one to RIA soon. This helps to motivate!

todd sharp's Gravatar Glad you like it - please let me know if you use this, i'd love to see what you're doing with it.

Hope to see your project too - I'm a huge proponent of Open Source - RIAForge rules!

Ben G's Gravatar I've been using http://code.google.com/p/gapi-google-analytics-php... since I've had to use PHP, but if I get to use ColdFusion again I will definitely take a look at this.

Matt Busche's Gravatar Is it just me or are you whispering in the video? Other than me struggling to hear what you're saying nice work

todd sharp's Gravatar Someone else mentioned that to me too. I did record it at about midnight last night, so maybe I was trying to not wake up the wife and kids :)

I'll make sure to talk louder, or turn up the level on my mic next time.

Robert Rawlins's Gravatar Just been putting some thought into some Analytics integration into our application to form a bit of a mash-up with out campaign distribution information along with website hits, this could prove a very usefully component indeed.

Thanks my man,

Rob

Kostas's Gravatar I'm looking for an 'upload' function for Google Docs API in addition to the download one.

What I got so far is:

<cffunction name="upload" access="public" returnType="any" hint="I upload the document." output="false">
<cfargument name="myFile" type="string" required="true" hint="file to upload.">

<cfset var result = "">
<cfset var service = variables.docservice>

<cfset theUrl = "https://docs.google.com/feeds/documents/private/fu... HTTP/1.1">

<cfhttp url="#theURL#" method="post" result="result">
<cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#getAuth(service)#">
<cfhttpparam type="header" name="Content-Length" value="81047">
<cfhttpparam type="header" name="Content-Type" value="application/msword">
<cfhttpparam type="header" name="Slug" value="#myFile#">
</cfhttp>

<cfreturn result.filecontent>

</cffunction>

But I get the following error when I output the result: 'Invalid request URI'

Anyone can help me out?

Andrew Maurer's Gravatar Thanks Todd for this CFC, worked nicely right out of the box.

I did find a cfdump on line 32 of analytics.cfc, you may want to remove that.

Thanks again!