views:

328

answers:

1

I would like to use the gdata API to retrieve some event entries from a public calendar feed. Here is the code that I'm using:

var calendarService = new google.gdata.calendar.CalendarService('GoogleInc-jsguide-1.0');

var feedUri = 'http://www.google.com/calendar/feeds/.../public/basic';
var gquery = new google.gdata.calendar.CalendarEventQuery(feedUri);

gquery.setFutureEvents(true);
gquery.setMaxResults(10);

var callback = function(result) {       
 var entries = result.feed.entry;    
 for (var i = 0; i < entries.length; i++ ) {
   var entry = entries[i];
   var title = entry.getTitle().getText();
   var times = entry.getTimes();
   alert("Title: " + title + " | Times: " + times);
 }    
}
calendarService.getEventsFeed(gquery, callback);

(Feed URI is the public (or private) XML-Feed for a Google Apps Calendar)

I expected to find the event times in times but it is an empty array. Which is in some way logical, because the actual feed in feedUri doesn't contain any time information.

Questions:

  • What am I doing wrong? How to retreive calendar entries which include event times?
  • Why is there a method getTimes() if it's completely useless?
+3  A: 

EDIT: I've just seen you're using the "basic" feed - have you tried the "full" feed instead? The description of the basic feed is:

Basic Atom feed without any extension elements. Its and properties contain pre-rendered HTML.

Additionally, you need to be aware of single events vs recurrent events. Information about recurrent events is available via getRecurrence(). For individual events, getTimes() will give the right information.

If you don't see the information via the API, try looking at the source data directly and see whether you can see it there.

Jon Skeet
Using the full feed solved the "problem" :D
Martin