要求
HTTP 要求
POST https://www.googleapis.com/calendar/v3/users/me/calendarList
參數
參數名稱 | 值 | 說明 |
---|---|---|
自選查詢參數 | ||
colorRgbFormat |
boolean |
是否使用 foregroundColor 和 backgroundColor 欄位寫入日曆顏色 (RGB)。如果使用這項功能,系統會將以索引為基礎的 colorId 欄位自動設為最符合的選項。選用設定。預設值為「False」。 |
授權
此要求需要取得下列範圍的授權:
範圍 |
---|
https://www.googleapis.com/auth/calendar |
詳情請參閱驗證和授權頁面。
要求主體
在要求內容中,提供具有以下屬性的 calendarList 資源:
資源名稱 | 值 | 說明 | 附註 |
---|---|---|---|
必要屬性 | |||
id |
string |
日曆的 ID。 | |
選用屬性 | |||
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(); // Create a new calendar list entry CalendarListEntry calendarListEntry = new CalendarListEntry(); calendarListEntry.setId("calendarId"); // Insert the new calendar list entry CalendarListEntry createdCalendarListEntry = service.calendarList().insert(calendarListEntry).execute(); System.out.println(createdCalendarListEntry.getSummary());
Python
使用 Python 用戶端程式庫。
calendar_list_entry = { 'id': 'calendarId' } created_calendar_list_entry = service.calendarList().insert(body=calendar_list_entry).execute() print created_calendar_list_entry['summary']
PHP
使用 PHP 用戶端程式庫。
$calendarListEntry = new Google_Service_Calendar_CalendarListEntry(); $calendarListEntry->setId("calendarId"); $createdCalendarListEntry = $service->calendarList->insert($calendarListEntry); echo $createdCalendarListEntry->getSummary();
Ruby
使用 Ruby 用戶端程式庫。
entry = Google::Apis::CalendarV3::CalendarListEntry.new( id: 'calendarId' ) result = client.insert_calendar_list(entry) print result.summary
試試看!
您可以使用下方的 APIs Explorer,針對即時資料呼叫這個方法,然後查看回應。