Events: move

將活動移至其他日曆,例如變更活動的主辦者。請注意,只能移動 default 事件;無法移動 outOfOfficefocusTimeworkingLocation 事件。立即試用查看範例

要求

HTTP 要求

POST https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId/move

參數

參數名稱 說明
路徑參數
calendarId string 活動目前所在來源日曆的日曆 ID。
eventId string 事件 ID。
必要的查詢參數
destination string 活動前往目標日曆的日曆 ID。
自選查詢參數
sendNotifications boolean 已淘汰,請改用 sendUpdates

是否要傳送活動發起人變更的通知。請注意,即使您將值設為 false,系統仍可能會傳送某些電子郵件。預設值為 false
sendUpdates string 應接收活動發起人變更通知的邀請對象。

可接受的值為:
  • all」:系統會將通知傳送給所有邀請對象。
  • externalOnly」:通知只會傳送給非 Google 日曆邀請對象。
  • none」:不傳送任何通知。如果是日曆遷移工作,請考慮改用 Events.import 方法。

授權

此要求至少需要以下其中一個範圍的授權:

範圍
https://www.googleapis.com/auth/calendar
https://www.googleapis.com/auth/calendar.events

詳情請參閱驗證和授權頁面。

要求主體

請勿使用這個方法提供要求主體。

回應

如果成功,這個方法會在回應主體中傳回事件資源

範例

注意:這個方法適用的程式語言眾多,我們只在此提供部分程式碼範例,完整的支援語言清單請參閱用戶端程式庫頁面

Java

使用 Java 用戶端程式庫

import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.Event;

// ...

// Initialize Calendar service with valid OAuth credentials
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
    .setApplicationName("applicationName").build();

// Move an event to another calendar
Event updatedEvent =
    service.events().move('primary', "eventId", "destinationCalendarId").execute();

System.out.println(updatedEvent.getUpdated());

Python

使用 Python 用戶端程式庫

# First retrieve the event from the API.
updated_event = service.events().move(
    calendarId='primary', eventId='eventId',
    destination='destinationCalendarId').execute()

# Print the updated date.
print updated_event['updated']

PHP

使用 PHP 用戶端程式庫

$result = $service->events->move('primary', 'eventId', 'destinationCalendarId');

// Print the updated date.
echo $result->getUpdated();

Ruby

使用 Ruby 用戶端程式庫

result = client.move_event('primary', 'eventId', 'destinationCalendarId')
print result.updated

試試看!

您可以使用下方的 APIs Explorer,針對即時資料呼叫這個方法,然後查看回應。