Raymond Camden's Blog Rss

GoogleCalendar.cfc Version 0

14

Posted in ColdFusion | Posted on 04-20-2006 | 2,777 views

I've attached to this entry the first version of the GoogleCalendar.cfc. There is no documentation yet so use at your own risk. What it does:

  • ReadEntries will return a query of events. Most of the columns should be obvious.
  • ReadMeta returns the meta information about the calendar. What you care about is the title field.
  • XML is cached so a HTTP call is only done once. I may also add caching of the entry data since it doesn't make sense to parse it N times.

What it does not yet do:

  • Translate times to the right timezone. To make this work, I think I'm going to require folks to send to ReadEntries their GMT offset.
  • Translate recurrence. This will be done, and will be sweet. It's going to be a nice string like "Daily", "Yearly", etc.
  • Add entries.
  • Simple way to force a refresh of the cache.

I've included a test script that read US Holidays. Very, very important note. The Google Calendar API lets you tweak how much data is returned. The default URL for your private calendar ends in "basic". You must change this to "full". Look at my test script for an example. I may end up making a basic check for this so folks don't forget.

Here is an example of how the API is used:

view plain print about
1<cfapplication name="gCal">
2
3<cfset reload = true>
4<cfif not structKeyExists(application, "gCal") or reload>
5    <cfset application.gCal = createObject("component", "GoogleCalendar").init("long as heck url here/full")>
6</cfif>
7
8<cfset r = application.gCal.readEntries()>
9<cfdump var="#r#">
10
11<cfset m = application.gCal.readMeta()>
12<cfdump var="#m#">

Download attached file

Comments

[Add Comment] [Subscribe to Comments]

Jeez Ray, are you in a hurry or something? Posting a CFC only three hours after mentioning that the API's out?
I'm a fast coder. ;)
Are you effing kidding me? You did this already? Christ Ray...I hate you. ;)
Later tonight I'm going to wrap up the Read part. It's really not that much left to do. The biggest dang thing will be the TZ conversions.

The "published" field is the date of the event (noticed I copied it to date). It is GMT as far as I can see. But the Start and End Times seem to be based on GMT-7. So to 'fix' it I need to diff it against your offset.
My Calendar URL doesn't have the URL values at the end. My URI is http://www.google.com/calendar/render
i got this error....


An error occured while Parsing an XML document.
123 : <cfset variables.calendarXML = xmlParse(results.fileContent)>
Michael, you don't want the URL in the browser. You want the URL you get from the XML link in the calendar settings.

Sunny: See if this helps.
An error occured while Parsing an XML document.
Content is not allowed in prolog.
SUnny, share your URL. If it is your private calendar, then send it to me via email.
I forgot to say. Use the XML url, NOT the ical url. Your URL should say feeds in it, not ical.
doh....

that worked.
Just an FYI, I've got time zone offsets working locally. Now your Date, Start, and End Time appear right for your TZ. It's up to you to figure out the TZ, but if it is equal to your box, you can use CF's getTimeZoneInfo().

You can also refresh the cache by calling update().

If folks want it right now, let me know and I'll update the zip. (After lunch anyway.)

Next is translating recurrences.
Oh and hey, don't forget that if you like this, you can always visit my wishlist. ;)
Ray, you have too much time on your hands! Don't you have a family or somthing??

Looks swwweet though! Roll on version 1.0

[Add Comment] [Subscribe to Comments]