0
我尝试实现两种方式将应用与Google日历同步。我没有找到合理的描述重现事件如何工作。他们是否在主要活动中重复(有自己的ID)? Google日历API(listEvents)仅返回带重复事件的主要事件(字符串)。当复发没有自己的ID时,我如何删除它们?当我从API(listEvents)的数据中删除系列中的一个重复事件(在谷歌日历中)时,没有提到关于该遗漏的重复事件。谷歌日历工作中的重复事件
我尝试实现两种方式将应用与Google日历同步。我没有找到合理的描述重现事件如何工作。他们是否在主要活动中重复(有自己的ID)? Google日历API(listEvents)仅返回带重复事件的主要事件(字符串)。当复发没有自己的ID时,我如何删除它们?当我从API(listEvents)的数据中删除系列中的一个重复事件(在谷歌日历中)时,没有提到关于该遗漏的重复事件。谷歌日历工作中的重复事件
重复发生的事件是一系列单个事件(实例)。您可以通过下面的链接了解有关情况:https://developers.google.com/google-apps/calendar/v3/reference/events/instances
如果你想删除重复事件(所有实例),你需要使用下面的代码:
$rec_event = $this->calendar->events->get('primary', $google_event_id);
if ($rec_event && $rec_event->getStatus() != "cancelled") {
$this->calendar->events->delete('primary', $google_event_id); // $google_event_id is id of main event with recurrences
}
如果你想删除所有的下列情况一些日期,你需要得到所有实例在该日期之后,然后循环删除:
$opt_params = array('timeMin' => $isoDate); // date of DATE_RFC3339 format, "Y-m-d\TH:i:sP"
$instances = $this->calendar->events->instances($this->calendar_id, $google_event_id, $opt_params);
if ($instances && count($instances->getItems())) {
foreach ($instances->getItems() as $instance) {
$this->calendar->events->delete('primary', $instance->getId());
}
}
如果你想添加例外(删除复发性事件只有一个实例),需要使用几乎相同的代码,但与其他过滤接r:
$opt_params = array('originalStart' => $isoDate); // exception date
$instances = $this->calendar->events->instances($this->calendar_id, $google_event_id, $opt_params);
if ($instances && count($instances->getItems())) {
foreach ($instances->getItems() as $instance) {
$this->calendar->events->delete('primary', $instance->getId());
}
}