Events: watch
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
留意事件資源是否有異動。
要求
HTTP 要求
POST https://www.googleapis.com/calendar/v3/calendars/calendarId/events/watch
參數
參數名稱 |
值 |
說明 |
路徑參數 |
calendarId |
string |
日曆 ID。如要擷取日曆 ID,請呼叫 calendarList.list 方法。如果您想存取目前登入使用者的主日曆,請使用「primary 」關鍵字。
|
選用查詢參數 |
eventTypes |
string |
要監控的資源事件類型。選用設定。這個參數可重複多次,用於監控不同類型的資源。如未設定,則會傳回所有事件類型。
可接受的值如下:
- 「
birthday 」:每年重複發生的特殊全天活動。
- 「
default 」:定期活動。
- 「
focusTime 」:專注時間活動。
- 「
fromGmail 」:Gmail 中的活動。
- 「
outOfOffice 」:不在辦公室的活動。
- 「
workingLocation 」:工作地點事件。
|
授權
這項要求允許使用下列其中一個範圍進行授權:
範圍 |
https://www.googleapis.com/auth/calendar.readonly |
https://www.googleapis.com/auth/calendar |
https://www.googleapis.com/auth/calendar.events.readonly |
https://www.googleapis.com/auth/calendar.events |
https://www.googleapis.com/auth/calendar.app.created |
https://www.googleapis.com/auth/calendar.events.freebusy |
https://www.googleapis.com/auth/calendar.events.owned |
https://www.googleapis.com/auth/calendar.events.owned.readonly |
https://www.googleapis.com/auth/calendar.events.public.readonly |
詳情請參閱「驗證與授權」頁面。
要求主體
在要求主體中,請按照下列結構提供資料:
{
"id": string,
"token": string,
"type": string,
"address": string,
"params": {
"ttl": string
}
}
屬性名稱 |
值 |
說明 |
附註 |
id |
string |
用於識別這個管道的 UUID 或類似的專屬字串。 |
|
token |
string |
每當透過這個管道傳送通知時,就會將任意字串傳送至目標地址。選填。 |
|
type |
string |
這個管道使用的放送機制類型。有效值為「web_hook 」(或「webhook 」)。這兩個值都代表使用 HTTP 要求傳送訊息的管道。 |
|
address |
string |
這個管道會將通知傳送至這個位址。 |
|
params |
object |
控制提交管道行為的其他參數。選填。 |
|
params.ttl |
string |
通知管道的存留時間 (以秒為單位)。預設值為 604800 秒。 |
|
回應
如果成功的話,這個方法會傳回回應內文,其結構如下:
{
"kind": "api#channel",
"id": string,
"resourceId": string,
"resourceUri": string,
"token": string,
"expiration": long
}
屬性名稱 |
值 |
說明 |
附註 |
kind |
string |
指出這是用來監控資源變更的通知管道,也就是「api#channel 」。 |
|
id |
string |
用於識別這個管道的 UUID 或類似的專屬字串。 |
|
resourceId |
string |
這個不易解讀的 ID 可識別這個管道中正在監控的資源。在不同 API 版本中皆穩定運作。 |
|
resourceUri |
string |
受監控資源的版本專屬 ID。 |
|
token |
string |
每當透過這個管道傳送通知時,就會將任意字串傳送至目標地址。選填。 |
|
expiration |
long |
通知管道到期日期和時間,以 Unix 時間戳記 (以毫秒為單位) 表示。選填。 |
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[],[],null,["# Events: watch\n\n| **Note:** [Authorization](#auth) optional.\n\nWatch for changes to Events resources.\n\nRequest\n-------\n\n### HTTP request\n\n```\nPOST https://www.googleapis.com/calendar/v3/calendars/calendarId/events/watch\n```\n\n### Parameters\n\n| Parameter name | Value | Description |\n|----------------|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Path parameters** |||\n| `calendarId` | `string` | Calendar identifier. To retrieve calendar IDs call the [calendarList.list](/workspace/calendar/api/v3/reference/calendarList/list) method. If you want to access the primary calendar of the currently logged in user, use the \"`primary`\" keyword. |\n| **Optional query parameters** |||\n| `eventTypes` | `string` | Event types of resources to watch. Optional. This parameter can be repeated multiple times to watch resources of different types. If unset, returns all event types. \u003cbr /\u003e \u003cbr /\u003e Acceptable values are: - \"`birthday`\": Special all-day events with an annual recurrence. - \"`default`\": Regular events. - \"`focusTime`\": Focus time events. - \"`fromGmail`\": Events from Gmail. - \"`outOfOffice`\": Out of office events. - \"`workingLocation`\": Working location events. |\n\n### Authorization\n\nThis request allows authorization with at least one of the following scopes:\n\n| Scope |\n|-------------------------------------------------------------------|\n| `https://www.googleapis.com/auth/calendar.readonly` |\n| `https://www.googleapis.com/auth/calendar` |\n| `https://www.googleapis.com/auth/calendar.events.readonly` |\n| `https://www.googleapis.com/auth/calendar.events` |\n| `https://www.googleapis.com/auth/calendar.app.created` |\n| `https://www.googleapis.com/auth/calendar.events.freebusy` |\n| `https://www.googleapis.com/auth/calendar.events.owned` |\n| `https://www.googleapis.com/auth/calendar.events.owned.readonly` |\n| `https://www.googleapis.com/auth/calendar.events.public.readonly` |\n\nFor more information, see the [authentication and authorization](/workspace/guides/configure-oauth-consent) page.\n\n### Request body\n\nIn the request body, supply data with the following structure:\n\n```carbon\n{\n \"id\": string,\n \"token\": string,\n \"type\": string,\n \"address\": string,\n \"params\": {\n \"ttl\": string\n }\n}\n```\n\n| Property name | Value | Description | Notes |\n|---------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|\n| `id` | `string` | A UUID or similar unique string that identifies this channel. | |\n| `token` | `string` | An arbitrary string delivered to the target address with each notification delivered over this channel. Optional. | |\n| `type` | `string` | The type of delivery mechanism used for this channel. Valid values are \"`web_hook`\" (or \"`webhook`\"). Both values refer to a channel where Http requests are used to deliver messages. | |\n| `address` | `string` | The address where notifications are delivered for this channel. | |\n| `params` | `object` | Additional parameters controlling delivery channel behavior. Optional. | |\n| params.`ttl` | `string` | The time-to-live in seconds for the notification channel. Default is 604800 seconds. | |\n\nResponse\n--------\n\nIf successful, this method returns a response body with the following structure:\n\n```text\n{\n \"kind\": \"api#channel\",\n \"id\": string,\n \"resourceId\": string,\n \"resourceUri\": string,\n \"token\": string,\n \"expiration\": long\n}\n```\n\n| Property name | Value | Description | Notes |\n|---------------|----------|-------------------------------------------------------------------------------------------------------------------|-------|\n| `kind` | `string` | Identifies this as a notification channel used to watch for changes to a resource, which is \"`api#channel`\". | |\n| `id` | `string` | A UUID or similar unique string that identifies this channel. | |\n| `resourceId` | `string` | An opaque ID that identifies the resource being watched on this channel. Stable across different API versions. | |\n| `resourceUri` | `string` | A version-specific identifier for the watched resource. | |\n| `token` | `string` | An arbitrary string delivered to the target address with each notification delivered over this channel. Optional. | |\n| `expiration` | `long` | Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional. | |"]]