Google Contacts Wrapper

Earlier today a user asked if I knew anything about reading Google contact information. I wasn't aware of an API for this, but turns out, one did exist (Contacts Data API). I think I'm finally getting used to the Google way of thinking when it comes to APIs (although see my PS at the bottom), so this one was rather easy to set up.

I just released the GoogleContacts project at RIAForge. This is a simple CFC that can retrieve both contacts and groups from your account. It doesn't support writing back to the system yet. Nor does it support dynamic data. (Google lets you put arbitrary name/value pairs into a contact, which is kind of nice.)

p.s. For folks who use my YouTube wrapper, the engineers on the YT team changed something on the back end that broke many people's implementation of the Upload API. A user reported the bug to me this week and I've been working on fixing it, but it's rather low level so it may be a few more days before it is fixed.

From what I know - this change wasn't announced. When I looked on the forums I saw a bunch of messages from folks wondering why various libraries stopped working all of a sudden. If you manage an API, I really think you have to go out of your way to manage changes, even simple changes, to ensure you don't leave your customers hanging. From what I know, their change was to essentially get a bit more strict, so in theory the change should not have broken any client. Still though, perhaps a bit more warning would have been nice!

Comments

Nice stuff, Ray. I've been playing around with the wrapper and it works really well. The only thing I noticed was that it didn't work with 'Google apps for my domain'. To get it to work I just added another cfhttpparam (name="accountType" value="HOSTED_OR_GOOGLE") to the cfhttp call in the getAuthCode method on the base.cfc component. Hope that helps someone.
# Posted By Sam Clement | 9/10/08 8:53 PM
Can you file a bug report for that please? I'm going to be applying base.cfc to my Calendar code as well.
# Posted By Raymond Camden | 9/10/08 9:03 PM
I've been working to extend the component to add a contact. A few details might help someone else.

First, it took a little fiddling to figure out the correct format to send the http request. Here's what I came up with:

<cfhttp url="#addContactUrl#" method="post" result="result">
   <cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#variables.authcode#">
<cfhttpparam type="header" name="Content-Type" value="application/atom+xml">
         <cfhttpparam type="body" value="#entry#">
      </cfhttp>

Second, if you want to add a contact to a group immediately, you need to add the namespace definition for gContact to the entry tag, like so:

<atom:entry xmlns:atom='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' xmlns:gContact='http://schemas.google.com/contact/2008'>

Nando
# Posted By Nando | 10/26/08 1:02 PM
Nando, do you want to add this to the project?
# Posted By Raymond Camden | 10/26/08 10:34 PM