Google Calendar API – add more fields

The other day I was busy integrating the Google Calendar API for a events website and after working with the API you begin to realise how limited your are with the fields the Google Calendar API makes available to you. It only returns limited fields that is available for a event. In the article I am going to show you how to add more fields. It’s not a perfect solution, but it gets the job done.

Google Calendar API

The new Google Calendar API (v3) is very limited when you want to add more data especially more fields which is not currently possible.

Also the widgets under the Google Calendar Labs does not integrate with the API so you can’t pull in data stored in the add-on widgets like attachments for example. I have found a way to “attach a image” to an event. I will explain this a bit later in the article.

Google Calendar > Settings > Labs https://www.google.com/calendar/render#m

It is also made quite clear on the Lab page.:

Google Calendar Labs is a testing ground for experimental features that aren’t quite ready for primetime. They may change, break or disappear at any time.

This is what the current events editor looks like when you want to add a event. The areas mark in Red is the only fields that you can retrieve.

Google_Calendar Event

This makes is a bit boring. What if you organise events and you need to add more info like the cost, contact person, email address and more?

Google Calendar API custom fields

Basically this is what is available in the array returned by the Google Calendar API. Not much hey?

To be able to add more data to a Google Calendar event do the following. Yes its not perfect, but it works well for a temporary solution until Google give you the option to add more data fields.

In the description box add all your information separated by pipes ” | ” for example.:

Description box.:

You will need to make a note in the order the data is stored for example.:

Image | Cost | Description | Contact Number | Email Address

Now when you make a connection to the Google Calendar API and you pull in all the fields from the array you will notice the description variable inside the array of data been pulled. This Description variable now contains allot more data fields separate by a pipe ” | “.

The two functions I use to pull in a specific event and then to pull the information apart in the description variable.:

From the above code you will notice that I explode the description variable into a array of items using the pipe ” |” as the string delimiter. So now I have whole lot more physicals data fields I can manipulate or inject into a database with each data value into its own field.

O…before I forget. To “include a image” with your event you can use the Flickr API. So basically you create a flickr account just for Google Calendar events. Upload images to that Flickr account. Now you can pull them into your application via the flickr API with the photo_id(s) you specified in the description field of the Google Calendar Event.

This is how I did it.:

So there you have it. This is the best way I could find to add more “fields” to my Google Calendar Events.

Also as a extra bonus if you want to start playing with date ranges. For example to display all the events for one year plus one month see the following code.:

I hope that I sparked off some ideas and that this article helps you on your quest to build better Google Calendar integrations. Have fun!

If you want to use my code just remember to credit me and include a reference to my website.