Martin Thurau
Martin Thurau

Reputation: 7644

Google Javascript Data API for Calendar - Event times not available

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:

Upvotes: 1

Views: 1083

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500155

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.

Upvotes: 3

Related Questions