how to copy every new event in google calendar from this time to another calendar via API?

I want to make an auto copy for every new event (ussualy an reccursive event) to another google calendar, via API.

i tried to do it with this code, but it copy also old events that their date are in the future.

    function copyEvents() {
  var calendarSource = CalendarApp.getCalendarById("calendarSourceId");
  var calendarDestination = CalendarApp.getCalendarById("calendarDestinationId");
  var eventToCopy = calendarSource.getEvents(new Date("February 6, 2016 EST"), new Date("July 22, 2100 EST"));


  for (var i in eventToCopy){
    var newEvent = calendarDestination.createEventSeries(eventToCopy[i].getTitle(), eventToCopy[i].getStartTime(), eventToCopy[i].getEndTime(), eventToCopy[i].getEventSeries());
  }
}

Answers


You may get the creation time of the event by calling 'Events.created' and use 'Events:move' to move an event to another calendar.

Here's a HTTP Request for moving an event to another calendar: POST https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId/move

For more details, follow this link: https://developers.google.com/google-apps/calendar/v3/reference/events/move


Need Your Help

How to use a JSON API?

javascript jquery html json api

I know this is probably a bit to "large" question to ask, but I have this JSON API I want to use and I have never used an API before and don't exactly know how to use it, I have read a bit on how t...

Apache mod_rewrite help with Wordpress

apache wordpress .htaccess mod-rewrite

I administer my wife's site, namelymarly.com. Up until last week, the root page of the blog was namelymarly.com/blog/.