要求
HTTP 要求
PUT https://www.googleapis.com/calendar/v3/users/me/calendarList/calendarId
參數
參數名稱 | 值 | 說明 |
---|---|---|
路徑參數 | ||
calendarId |
string |
日曆 ID。如要擷取日曆 ID,請呼叫 calendarList.list 方法。如果要存取目前登入使用者的主要日曆,請使用「primary 」關鍵字。
|
自選查詢參數 | ||
colorRgbFormat |
boolean |
是否使用 foregroundColor 和 backgroundColor 欄位寫入日曆顏色 (RGB)。如果使用這項功能,系統會將以索引為基礎的 colorId 欄位自動設為最符合的選項。選用設定。預設值為「False」。 |
授權
此要求需要取得下列範圍的授權:
範圍 |
---|
https://www.googleapis.com/auth/calendar |
詳情請參閱驗證和授權頁面。
要求主體
在要求內容中,提供具有以下屬性的 calendarList 資源:
資源名稱 | 值 | 說明 | 附註 |
---|---|---|---|
選用屬性 | |||
backgroundColor |
string |
以十六進位格式 "#0088aa " 的日曆主要顏色。這個屬性會取代以索引為基礎的 colorId 屬性。如要設定或變更這個屬性,您必須在 insert、update 和 patch 方法的參數中指定 colorRgbFormat=true 。選用。 |
可寫入 |
colorId |
string |
日曆的顏色。這個 ID 是指顏色定義中 calendar 部分的項目 (請參閱「顏色端點」)。這個屬性會由 backgroundColor 和 foregroundColor 屬性取代,且可在使用這些屬性時忽略。選用。 |
可寫入 |
defaultReminders[] |
list |
已驗證使用者為此日曆設定的預設提醒。 | 可寫入 |
defaultReminders[].method |
string |
這則提醒使用的方法。可能的值包括:
新增提醒時必須提供。 |
可寫入 |
defaultReminders[].minutes |
integer |
活動開始前的分鐘數,應在活動開始之前觸發。有效值介於 0 到 40320 (4 週以分鐘為單位) 之間。 新增提醒時必須提供。 |
可寫入 |
foregroundColor |
string |
日曆的前景顏色採用十六進位格式「#ffffff 」。這個屬性取代以索引為基礎的 colorId 屬性。如要設定或變更這個屬性,您必須在 insert、update 和 patch 方法的參數中指定 colorRgbFormat=true 。選用。 |
可寫入 |
notificationSettings |
object |
已驗證使用者收到的這個日曆通知。 | 可寫入 |
notificationSettings.notifications[].method |
string |
用於傳送通知的方法。可能的值為:
新增通知時必須提供。 |
可寫入 |
notificationSettings.notifications[].type |
string |
通知類型,可能的值包括:
新增通知時必須提供。 |
可寫入 |
selected |
boolean |
日曆 UI 是否顯示日曆內容。選用設定。預設值為「False」。 | 可寫入 |
summaryOverride |
string |
已驗證使用者為此日曆設定的摘要。選用。 | 可寫入 |
回應
如果成功的話,這個方法會在回應主體中傳回 calendarList 資源。
範例
注意:這個方法適用的程式語言眾多,我們只在此提供部分程式碼範例,完整的支援語言清單請參閱用戶端程式庫頁面。
Java
使用 Java 用戶端程式庫。
import com.google.api.services.calendar.Calendar; import com.google.api.services.calendar.model.CalendarListEntry; // ... // Initialize Calendar service with valid OAuth credentials Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials) .setApplicationName("applicationName").build(); // Retrieve the calendar list entry CalendarListEntry calendarListEntry = service.calendarList().get("calendarId").execute(); // Make a change calendarListEntry.setColorId("newColorId"); // Update the altered entry CalendarListEntry updatedCalendarListEntry = service.calendarList().update(calendarListEntry.getId(), calendarListEntry).execute(); System.out.println(updatedCalendarListEntry.getEtag());
Python
使用 Python 用戶端程式庫。
# First retrieve the calendarListEntry from the API. calendar_list_entry = service.calendarList().get(calendarId='calendarId').execute() calendar_list_entry['colorId'] = 'newColorId' updated_calendar_list_entry = service.calendarList().update( calendarId=calendar_list_entry['id'], body=calendar_list_entry).execute() print created_calendar_list_entry['etag']
PHP
使用 PHP 用戶端程式庫。
// First retrieve the calendarListEntry from the API. $calendarListEntry = $service->calendarList->get('calendarId'); $calendarListEntry->setColorId('newColorId'); $updatedCalendarListEntry = service->calendarList->update($calendarListEntry->getId(), $calendarListEntry); echo $updatedCalendarListEntry->getEtag();
Ruby
使用 Ruby 用戶端程式庫。
calendar_list_entry = client.get_calendar_list('calendarId') calendar_list_entry.colorId = 'newColorId' result = client.update_calendar_list(calendar_list_entry.id, calendar_list_entry) print result.etag
試試看!
您可以使用下方的 APIs Explorer,針對即時資料呼叫這個方法,然後查看回應。