Google Calendar API – Update

Google updated their calendar API (from version 2 to version 3), and how much simpler it all is.  No more “gdata” objects, the whole thing has been moved to a RESTful model with the data being returned as JSON. Accessing the calendar data couldn’t be simpler using AJAX from a web page.

xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
 if (xmlhttp.readyState==4 && xmlhttp.status==200)
 {
 var obj = JSON.parse(xmlhttp.responseText);
 var elem = obj.items;
 elem.forEach(function(entry) {
 console.log(entry.summary);
 });
 }
 }
 xmlhttp.open("GET","https://www.googleapis.com/calendar/v3/calendars/qqqqqqqqqqqqqqqqqqqqqqqqqq%40group.calendar.google.com/events?singleEvents=true&key=XXXXXX-YYYYYYYYYYYYYYY_ZZZZZZZZZZZZZZZ",true);
 xmlhttp.send();

where ‘qqqqqqqqqqqqqqqqqq%40group.calendar.google.com’ is your calendar ID, which can be found in the web interface to your calendar, under “settings”.  The “key” is the authentication key, which you’ll need to setup through the API console, accessible here: https://code.google.com/apis/console.  You can also configure the key so that its use can be restricted by referrer, so that only specific sites can make use of it.