Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Theo dõi các thay đổi đối với tài nguyên Sự kiện.
Yêu cầu
Yêu cầu HTTP
POST https://www.googleapis.com/calendar/v3/calendars/calendarId/events/watch
Thông số
Tên thông số
Giá trị
Mô tả
Thông số đường dẫn
calendarId
string
Giá trị nhận dạng lịch. Để truy xuất mã lịch, hãy gọi phương thức calendarList.list. Nếu bạn muốn truy cập vào lịch chính của người dùng hiện đã đăng nhập, hãy sử dụng từ khoá "primary".
Thông số truy vấn không bắt buộc
eventTypes
string
Loại sự kiện của tài nguyên cần theo dõi. Không bắt buộc. Bạn có thể lặp lại tham số này nhiều lần để theo dõi các tài nguyên thuộc nhiều loại. Nếu không được đặt, sẽ trả về tất cả các loại sự kiện.
Các giá trị được chấp nhận là:
"birthday": Sự kiện đặc biệt kéo dài cả ngày, lặp lại hằng năm.
"default": Sự kiện định kỳ.
"focusTime": Sự kiện thời gian tập trung.
"fromGmail": Sự kiện từ Gmail.
"outOfOffice": Sự kiện không có mặt tại văn phòng.
"workingLocation": Sự kiện vị trí làm việc.
Ủy quyền
Yêu cầu này cho phép uỷ quyền với ít nhất một trong các phạm vi sau:
UUID hoặc chuỗi duy nhất tương tự giúp xác định kênh này.
token
string
Một chuỗi tuỳ ý được phân phối đến địa chỉ mục tiêu cùng với mỗi thông báo được phân phối qua kênh này. Không bắt buộc.
type
string
Loại cơ chế phân phối được dùng cho kênh này. Các giá trị hợp lệ là "web_hook" (hoặc "webhook"). Cả hai giá trị đều đề cập đến một kênh mà các yêu cầu Http được dùng để phân phối thông báo.
address
string
Địa chỉ nơi thông báo được gửi cho kênh này.
params
object
Các tham số bổ sung kiểm soát hành vi của kênh phân phối. Không bắt buộc.
params.ttl
string
Thời gian tồn tại tính bằng giây cho kênh thông báo. Giá trị mặc định là 604800 giây.
Phản hồi
Nếu thành công, phương thức này sẽ trả về một phần nội dung phản hồi có cấu trúc sau:
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],[],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. | |"]]