开发者

Updating all instance of a recurring event in Google Calendar API

开发者 https://www.devze.com 2022-12-15 08:41 出处:网络
What is the proper way to upd开发者_StackOverflow中文版ate all (or a subset) of the instances of a recurring event?Also related:how do you, given the id of the original event, get the instances of tha

What is the proper way to upd开发者_StackOverflow中文版ate all (or a subset) of the instances of a recurring event? Also related: how do you, given the id of the original event, get the instances of that event?


If you want to update just a subset of recurring events, then you need to set singleevents = true when running your query to retrieve the initial list of events. In PHP you'd do something like this

  $gdataCal = new Zend_Gdata_Calendar($client);
  $query = $gdataCal->newEventQuery();
  $query->setUser('default');
  $query->setVisibility('private');
  $query->setProjection('full');
  $query->setOrderby('starttime');
  $query->setStartMin($startDate);
  $query->setStartMax($endDate);
  $query->setSingleEvents('true');  //get recurring events as a series of single events
  $eventFeed = $gdataCal->getCalendarEventFeed($query);

  foreach ($eventFeed as $event) {
    //do stuff with $event
  }


I tried with updating all recurrence event ,it is working.Initially I created one Recurring event like weekly on Monday from 2016-02-25 to 2016-03 25 and It is created 6 instances for that recurring period.During updating what I tried is,

1.First I assigned to Recurrence field , "recurrence":["RRULE:FREQ=WEEKLY;COUNT=18;BYDAY=TU"] (Updating like weekly on Tuesday)

2.after that I fetching available lists using list google api.here I used Single Events: false(in the sence it will give only main recurring event not all instances)

3.after I used update event to update like passing auth,eventId and calendarId: "primary" and resource:updated event array

then it is done .It is updating the instances as Weekly on Tuesday.

I hope it will help to someone.


To update all you just change the relevant properties for the event, leaving the recurrence and recurrence exceptions strings intact. Not sure that you can easily modify a subset, as this would require converting the recurring event into multiple new events depending on the subset.

For the second part or your question, according to the API docs:

Specifically, each recurring event is represented by a element in the result feed, and each of those elements includes a element for each occurrence of that event that falls between the start time and the end time. Looking at elements is much simpler than parsing recurrences and exceptions yourself.

However, I've never been able to find that magic "when"... so I've ended up parsing the recurrence and recurrenceexceptions strings - if you find the answer to that one, let us all know!


For anyone with this issue I also spent some time trying to figure this out. Basically when you get your CalendarEventEntry list you need to check for each calendarEventEntry if it has an originalEvent (calendarEventEntry.getOriginalEvent()). This basically tells you there is another event (which you may or may not have already processed) that needs to swapped with the information for this current calendarEventEntry.

0

精彩评论

暂无评论...
验证码 换一张
取 消