Google Calendar (API) questions

2019-07-18 11:27发布

I'd like to use Google Calendar for adding party events, so I added a new calendar, "events". Is there a function for deleting all events in that calendar?

Or is it only possible by deleting the whole calender and re-creating it?

I'm having offline data which updates daily, so I thought the best method would be flushing the whole Google Calendar calendar and simply uploading all events.

1条回答
别忘想泡老子
2楼-- · 2019-07-18 11:58

This is helpful: Google Calendar .NET API documentation.

// Create a CalenderService and authenticate
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
myService.setUserCredentials("jo@gmail.com", "mypassword");

// Create the query object:
EventQuery query = new EventQuery();
query.Uri = new Uri("https://www.google.com/calendar/feeds/[calendar]/private/full");

where [calendar] = "jo@gmail.com" for default calendar or in your instance, the ID of your 'events' calendar (found in calendar in Gmail), that is, https://www.google.com/calendar/[calendarID]/private/full"

// Tell the service to query:
EventFeed calFeed = myService .Query(query);

// This should delete all items in your calendar

foreach(var item in calFeed.Entries) {
    entry.Delete();
}
查看更多
登录 后发表回答