0

How can I programmatically delete events in a secondary calendar in Google calendar for a specific date range? I have been searching for a few days now and all the tutorials and questions answered so far only show how you can delete on the default calendar. Has anyone got an example of how I can delete events from a non-default calendar?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Rasika
  • 1,980
  • 13
  • 19

1 Answers1

1

It's a bit odd to answer my own question. But it might help someone else to save a lot of time. The hint was from this post.

Basically, when you are searching for the events to be deleted, how you set the non-default calendar is by changing the setUser part from

$query->setUser('default');

to

$query->setUser($UserPartFromSecondaryCalendarID);

The calendar ID for secondary calendars are in the form of http://www.google.com/calendar/feeds/default/XXXXXXXXXX. What you should be passing for $UserPartFromSecondaryCalendarID is XXXXXXXXXX. This can be easily achieved by splitting the calendar ID by '/' and getting the last element (6).

Rasika
  • 1,980
  • 13
  • 19