I am trying to get the list of upcoming events from a google calendar using their v3 api. I have used the following code
var eventName = '';
var today = new Date();
var iso = encodeURI(ISODateString(today));
var gclaData = 'https://www.googleapis.com/calendar/v3/calendars/[email protected]/events?singleEvents=true&maxResults=3&timeMin='+iso+'&key=AIzaSyCP4j-U4GzJri3zaADP4FM1aVsIJ0Mqhj4';
jQuery.getJSON(gclaData,function(data){
for(var i=0;i<data.items.length;i++){
var eventrow='<div class="row"><div class="col-md-3">'
var eventdate = new Date(data.items[i].start.dateTime);
eventrow+='<h4 class="eventheader">'+months[eventdate.getMonth()]+'</h4><h3 class="eventheader">'+eventdate.getDate()+'</h3></div>'
eventrow+='<div class="col-md-9"><h5 class="header blogtitle">'+data.items[i].summary+'</h5><p>'+data.items[i].description+'</p>'
eventrow+='<a href="'+data.items[i].htmlLink+'" target="_blank">More Details & Attend</a>'
eventrow+='<div class="spacer40"</div></div></div>'
jQuery('.gcal').append(eventrow);
}
if(!data.items.length) jQuery('.gcal').append('<h3 class="header">No Upcoming Events</h3>');
});
With the code above, I only get upcoming recurring events. If I remove the singleEvents = true, I get events in the past. I have tried many different variations but never what I want, a list of upcoming recurring and non-recurring events (so starting from today).
Does anybody see anything wrong with this code?