Google 日历 API > 编辑重复发生的事件 > 这个和后面的选项 > 保留例外
Google calendar API > Edit Recurring Events > this and following option > persist exceptions
我从 12 月 11 日到 12 月 20 日使用 Google-calendar-api 创建了一个循环系列。我在 12 月 18 日使用“仅此事件”选项对单个实例进行了更改(例如:描述)。
然后我将在 12 月 15 日编辑标题并选择“这个和后续”选项。这会重置我在 12 月 18 日(描述已更改)的异常以匹配 12 月 15 日的描述。
如 Google API 文档中所述,将 parent 系列拆分为两个 'this and following' 时如何保留系列的例外情况。
编辑:
要创建 Google 个周期性事件:
$event = new Google_Service_Calendar_Event([
'summary' => $meeting->title,
'location' => $meeting->location,
'start' => [
'date' => $all_day_startdate,
'dateTime' => $start_date_time,
'timeZone' => $timezone
],
'end' => [
'date' => $all_day_enddate,
'dateTime' => $end_date_time,
'timeZone' => $timezone
],
'conferenceData' => $conference_link,
]);
$event>setRecurrence(array(format_recurrence_rule_for_google($recurrence_pattern)));
// set Google calendar event parameters.
$calendar_id = 'primary';
$opt_params = [
'sendNotifications' => $send_invite,
'conferenceDataVersion' => 1
];
// create the Google calendar event
$event = $service->events->insert($calendar_id, $event, $opt_params);
要更新单个实例:
$event = new Google_Service_Calendar_Event([
'summary' => $meeting->title,
'location' => $meeting->location,
'start' => [
'date' => $all_day_startdate,
'dateTime' => $start_date_time,
'timeZone' => $meet_creator->timezone
],
'end' => [
'date' => $all_day_enddate,
'dateTime' => $end_date_time,
'timeZone' => $meet_creator->timezone
],
"recurringEventId" => $recurring_event_id,
"originalStartTime" => [
"dateTime" => $exist_event->getOriginalStartTime()->getDateTime(),
"timeZone" => $meet_creator->timezone
],
"iCalUID" => $exist_event->getiCalUID(),
'conferenceData' => event_conference($meeting->conference)
]);
$opt_params = [
'conferenceDataVersion' => ($generate_conf || $cancel_conf) ? 1 : 0
];
$calendar_id = 'primary';
$updatedEvent = $service->events->insert($calendar_id, $event, $opt_params);
此事件和后续事件代码段
$current_event = $this->get_instance_with_event_id($parent_meeting);
$rec = format_recurrence_rule_for_google($parent_meeting->meeting_options->recurrence);
$current_event->setRecurrence(array($rec));
// trim the parent recurring event into two
$service->events->update('primary', $parent_meeting->meeting_options->recurring_event_id, $current_event);
$event = $this->create_initial_calendar_event() // which is the first snippet to create recurring event
简答
不可能
说明
官方文档解释了如何使用 Recurring Events。它有一个部分展示了如何 修改所有后续实例 但是按照这些步骤你会得到两个分开的 Recurring Events
并且 exception instances
将消失。只有一种方法可以修改 instance
的某些参数并将它们应用于 此事件和后续事件 ,那就是使用 Calendar
的网络版本(它也尊重例外情况)。
解决方法
循环
更新和插入(查看官方文档here)
- Events: update to trim the event and (re)define the instances that are not going to change. The body request is an Event resource 需要用于创建原始
Recurring Event
的所有属性,并修改 recurrence
以涵盖所需的天数。
- Events: insert 插入具有修改属性的剩余实例。正文请求必须像上一步一样使用其所有属性进行定义。
- 缺点:它创建了两个不同的
Recurring Events
并且 Event resources
必须从零开始定义。它也与例外重叠。
获取、修补和插入(可以处理一些异常)
- Events: get 获取
Recurring Event
及其所有信息。
- Events: patch to trim the event and keep the
instances
that have the exceptions
. The body request is an Event resource 可以通过两种方式定义:
- 从零开始:只需要
start
、end
和recurrence
。使用 patch
保留所有其他参数。
- 来自之前用
get
获得的原始事件。在您的情况下,您需要将 start.dateTime
和 end.dateTime
修改为 12 月 15 日(和相应的时间)以及您要更改的新参数,例如 description
.
- Events: insert插入没有
exceptions
的剩余实例。此步骤中使用的 Event resource
是原始 Recurring Event
的克隆。有一些属性需要更改:iCalUID = ""
、id = ""
,对于您的情况,recurrence
以便在 12 月 15 日停止。
- 缺点:它创建了两个不同的
Recurring Events
并进行了三个不同的 API 调用。 exceptions
只维护一个Recurring Event
.
取消实例,插入新事件
- Events: instances 得到
Recurring Event
. 的 instances
Recurring Event
的 - Cancel an instance 更改其
status
:未取消的重复事件的已取消异常表明不应再向用户显示此实例。
- Events: insert 在与
cancelled instance
相同的日期插入新的 Event resource
以便将来对 Recurring Event
的更改不会更改此 exception
.可以从原文中获取属性instance
.
- 缺点:异常事件不属于
Recurring Event
.
参考资料
我从 12 月 11 日到 12 月 20 日使用 Google-calendar-api 创建了一个循环系列。我在 12 月 18 日使用“仅此事件”选项对单个实例进行了更改(例如:描述)。
然后我将在 12 月 15 日编辑标题并选择“这个和后续”选项。这会重置我在 12 月 18 日(描述已更改)的异常以匹配 12 月 15 日的描述。
如 Google API 文档中所述,将 parent 系列拆分为两个 'this and following' 时如何保留系列的例外情况。
编辑: 要创建 Google 个周期性事件:
$event = new Google_Service_Calendar_Event([
'summary' => $meeting->title,
'location' => $meeting->location,
'start' => [
'date' => $all_day_startdate,
'dateTime' => $start_date_time,
'timeZone' => $timezone
],
'end' => [
'date' => $all_day_enddate,
'dateTime' => $end_date_time,
'timeZone' => $timezone
],
'conferenceData' => $conference_link,
]);
$event>setRecurrence(array(format_recurrence_rule_for_google($recurrence_pattern)));
// set Google calendar event parameters.
$calendar_id = 'primary';
$opt_params = [
'sendNotifications' => $send_invite,
'conferenceDataVersion' => 1
];
// create the Google calendar event
$event = $service->events->insert($calendar_id, $event, $opt_params);
要更新单个实例:
$event = new Google_Service_Calendar_Event([
'summary' => $meeting->title,
'location' => $meeting->location,
'start' => [
'date' => $all_day_startdate,
'dateTime' => $start_date_time,
'timeZone' => $meet_creator->timezone
],
'end' => [
'date' => $all_day_enddate,
'dateTime' => $end_date_time,
'timeZone' => $meet_creator->timezone
],
"recurringEventId" => $recurring_event_id,
"originalStartTime" => [
"dateTime" => $exist_event->getOriginalStartTime()->getDateTime(),
"timeZone" => $meet_creator->timezone
],
"iCalUID" => $exist_event->getiCalUID(),
'conferenceData' => event_conference($meeting->conference)
]);
$opt_params = [
'conferenceDataVersion' => ($generate_conf || $cancel_conf) ? 1 : 0
];
$calendar_id = 'primary';
$updatedEvent = $service->events->insert($calendar_id, $event, $opt_params);
此事件和后续事件代码段
$current_event = $this->get_instance_with_event_id($parent_meeting);
$rec = format_recurrence_rule_for_google($parent_meeting->meeting_options->recurrence);
$current_event->setRecurrence(array($rec));
// trim the parent recurring event into two
$service->events->update('primary', $parent_meeting->meeting_options->recurring_event_id, $current_event);
$event = $this->create_initial_calendar_event() // which is the first snippet to create recurring event
简答
不可能
说明
官方文档解释了如何使用 Recurring Events。它有一个部分展示了如何 修改所有后续实例 但是按照这些步骤你会得到两个分开的 Recurring Events
并且 exception instances
将消失。只有一种方法可以修改 instance
的某些参数并将它们应用于 此事件和后续事件 ,那就是使用 Calendar
的网络版本(它也尊重例外情况)。
解决方法
循环
更新和插入(查看官方文档here)
- Events: update to trim the event and (re)define the instances that are not going to change. The body request is an Event resource 需要用于创建原始
Recurring Event
的所有属性,并修改recurrence
以涵盖所需的天数。 - Events: insert 插入具有修改属性的剩余实例。正文请求必须像上一步一样使用其所有属性进行定义。
- 缺点:它创建了两个不同的
Recurring Events
并且Event resources
必须从零开始定义。它也与例外重叠。
- Events: update to trim the event and (re)define the instances that are not going to change. The body request is an Event resource 需要用于创建原始
获取、修补和插入(可以处理一些异常)
- Events: get 获取
Recurring Event
及其所有信息。 - Events: patch to trim the event and keep the
instances
that have theexceptions
. The body request is an Event resource 可以通过两种方式定义:- 从零开始:只需要
start
、end
和recurrence
。使用patch
保留所有其他参数。 - 来自之前用
get
获得的原始事件。在您的情况下,您需要将start.dateTime
和end.dateTime
修改为 12 月 15 日(和相应的时间)以及您要更改的新参数,例如description
.
- 从零开始:只需要
- Events: insert插入没有
exceptions
的剩余实例。此步骤中使用的Event resource
是原始Recurring Event
的克隆。有一些属性需要更改:iCalUID = ""
、id = ""
,对于您的情况,recurrence
以便在 12 月 15 日停止。 - 缺点:它创建了两个不同的
Recurring Events
并进行了三个不同的 API 调用。exceptions
只维护一个Recurring Event
.
- Events: get 获取
取消实例,插入新事件
- Events: instances 得到
Recurring Event
. 的 - Cancel an instance 更改其
status
:未取消的重复事件的已取消异常表明不应再向用户显示此实例。 - Events: insert 在与
cancelled instance
相同的日期插入新的Event resource
以便将来对Recurring Event
的更改不会更改此exception
.可以从原文中获取属性instance
. - 缺点:异常事件不属于
Recurring Event
.
instances
Recurring Event
的- Events: instances 得到