Events: move

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

要求

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 用戶端程式庫

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

試試看!

使用下方的 APIs Explorer,針對即時資料呼叫這個方法,看看會有什麼結果。