Reputation: 8233
I'm currently getting events from Google Calendar API v3 (using Javascript).
I was stuck on getting access to the API : Google Calendar API V3 and Ajax : No 'Access-Control-Allow-Origin' header
And now, I'm a bit confused: I'm trying to get event list from few days (2012-07-31 to 2012-08-04, GMT+1), so here's what I tried :
gapi.client.load('calendar', 'v3').then(function(data) {
var request = gapi.client.calendar.events.list({
'calendarId': '[cal id]',
"timeMin": "2012-07-31T00:00:00+01:00",
"timeMax": "2012-08-05T00:00:00+01:00"
});
request.execute(function(resp) {
for (var i = 0; i < resp.items.length; i++) {
console.log(resp.items[i]);
};
});
});
But this request returns events with datetimes that doesn't seem to fit with what I requested: 2012-04-14T11:00:00+02:00, 2011-09-11
Any ideas ?
Upvotes: 1
Views: 1564
Reputation: 2352
You need to set 'singleEvents' to true which I believe returns individual instances of reoccurring events instead of the event group.
gapi.client.load('calendar', 'v3').then(function(data) {
var request = gapi.client.calendar.events.list({
'calendarId': '[cal id]',
'singleEvents': true,
"timeMin": "2012-07-31T00:00:00+01:00",
"timeMax": "2012-08-05T00:00:00+01:00"
});
request.execute(function(resp) {
for (var i = 0; i < resp.items.length; i++) {
console.log(resp.items[i]);
};
});
});
Upvotes: 1