我們正在更新 Data API,以符合 YouTube 計算 Shorts 觀看次數的方式。
瞭解詳情
Activities: insert
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
為特定頻道發布公告。(提交要求的使用者必須獲得授權,才能代表頻道採取行動)。
注意:雖然 activity
資源可以包含使用者對影片評分或將影片標示為喜好項目等動作的相關資訊,但您需要使用其他 API 方法來產生這些 activity
資源。舉例來說,您可以使用 API 的 videos.rate()
方法為影片評分,並使用 playlistItems.insert()
方法將影片標示為我的最愛。
配額影響:呼叫此方法會產生 50 個單位的配額費用。
要求
HTTP 要求
POST https://www.googleapis.com/youtube/v3/activities
授權
這項要求需要授權,且至少須具備下列其中一個範圍 (進一步瞭解驗證和授權)。
範圍 |
https://www.googleapis.com/auth/youtube |
https://www.googleapis.com/auth/youtube.force-ssl |
參數
下表列出這項查詢支援的參數。列出的所有參數都是查詢參數。
參數 |
必要參數 |
part |
string
在此作業中,part 參數有兩個用途。這會識別寫入作業將設定的屬性,以及 API 回應將包含的屬性。
下列清單包含可納入參數值的 part 名稱:
contentDetails
id
snippet
|
要求主體
在要求主體中提供活動資源。
該資源:
-
您必須為下列屬性指定值:
-
您可以為下列屬性設定值:
snippet.description
contentDetails.bulletin.resourceId
錯誤
下表列出 API 可能在呼叫這個方法時傳回的錯誤訊息。詳情請參閱錯誤訊息說明文件。
錯誤類型 |
錯誤詳細資料 |
說明 |
badRequest (400) |
bulletinTextRequired |
要求必須使用 snippet 物件的 description 屬性,提供公告貼文的文字。 |
badRequest (400) |
invalidMetadata |
kind 屬性與提供的 ID 類型不符。 |
forbidden (403) |
forbidden |
要求未獲得適當授權。 |
notFound (404) |
playlistNotFound |
YouTube 找不到您要與公告貼文建立關聯的影片。檢查 contentDetails.bulletinPosted.playlistId 屬性的值。 |
notFound (404) |
videoNotFound |
YouTube 找不到您要與公告貼文建立關聯的影片。檢查 contentDetails.bulletinPosted.videoId 屬性的值。 |
userRateLimitExceeded (403) |
rateLimitExceeded |
由於超出配額,因此無法完成要求。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-21 (世界標準時間)。
[null,null,["上次更新時間:2025-08-21 (世界標準時間)。"],[[["\u003cp\u003eYouTube's channel bulletin feature has been deprecated and is no longer supported.\u003c/p\u003e\n"],["\u003cp\u003eCreating an activity requires authorization with specific scopes, such as \u003ccode\u003ehttps://www.googleapis.com/auth/youtube\u003c/code\u003e or \u003ccode\u003ehttps://www.googleapis.com/auth/youtube.force-ssl\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epart\u003c/code\u003e parameter in the request specifies which properties will be modified and included in the API response, such as \u003ccode\u003econtentDetails\u003c/code\u003e, \u003ccode\u003eid\u003c/code\u003e, and \u003ccode\u003esnippet\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe request body must include an activity resource, and it is required to provide a value for \u003ccode\u003esnippet.description\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThis method call has a quota cost of 50 units, and exceeding the quota will result in a \u003ccode\u003euserRateLimitExceeded\u003c/code\u003e error.\u003c/p\u003e\n"]]],["The YouTube channel bulletin feature is deprecated. The API's `activities.insert` method allows posting to a channel. This requires authorization and has a quota cost of 50 units. You must provide `snippet.description` for the bulletin text in the request body. Key parameters include `part`, and the response returns an `activity` resource. Errors can occur due to bad requests, invalid metadata, authorization issues, or exceeding quota limits.\n"],null,["# Activities: insert\n\n**YouTube has deprecated the channel bulletin feature, and this method is no longer supported.** \n\nFor more details, please see the [YouTube Help Center](https://support.google.com/youtube?p=channel-bulletins).\nPosts a bulletin for a specific channel. (The user submitting the request must be authorized to act on the channel's behalf.) \n\n**Note:** Even though an `activity` resource can contain information about actions like a user rating a video or marking a video as a favorite, you need to use other API methods to generate those `activity` resources. For example, you would use the API's [videos.rate()](/youtube/v3/docs/videos/rate) method to rate a video and the [playlistItems.insert()](/youtube/v3/docs/playlistItems/insert) method to mark a video as a favorite.\n\n**Quota impact:** A call to this method has a [quota cost](/youtube/v3/getting-started#quota) of 50 units.\n\nRequest\n-------\n\n### HTTP request\n\n```\nPOST https://www.googleapis.com/youtube/v3/activities\n```\n\n### Authorization\n\nThis request requires authorization with at least one of the following scopes ([read more about authentication and authorization](/youtube/v3/guides/authentication)).\n\n| Scope |\n|-----------------------------------------------------|\n| `https://www.googleapis.com/auth/youtube` |\n| `https://www.googleapis.com/auth/youtube.force-ssl` |\n\n### Parameters\n\nThe following table lists the parameters that this query supports. All of the parameters listed are query parameters.\n\n| Parameters ||\n|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| **Required parameters** |||\n| `part` | `string` The **part** parameter serves two purposes in this operation. It identifies the properties that the write operation will set as well as the properties that the API response will include. The following list contains the `part` names that you can include in the parameter value: - `contentDetails` - `id` - `snippet` |\n\n### Request body\n\nProvide an [activity resource](/youtube/v3/docs/activities#resource) in the request body.\nFor that resource:\n\n- You must specify a value for these properties:\n\n - `snippet.description`\n- You can set values for these properties:\n\n - `snippet.description`\n - `contentDetails.bulletin.resourceId`\n\nResponse\n--------\n\nIf successful, this method returns an [activity resource](/youtube/v3/docs/activities#resource) in the response body.\n\nErrors\n------\n\nThe following table identifies error messages that the API could return in response to a call to this method. Please see the [error message](/youtube/v3/docs/errors) documentation for more detail.\n\n| Error type | Error detail | Description |\n|-------------------------------|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `badRequest (400)` | `bulletinTextRequired` | The request must use the `snippet` object's `description` property to provide the text for the bulletin post. |\n| `badRequest (400)` | `invalidMetadata` | The `kind` property does not match the type of ID provided. |\n| `forbidden (403)` | `forbidden` | The request is not properly authorized. |\n| `notFound (404)` | `playlistNotFound` | YouTube cannot find the video that you are trying to associate with the bulletin post. Check the value of the `contentDetails.bulletinPosted.playlistId` property. |\n| `notFound (404)` | `videoNotFound` | YouTube cannot find the video that you are trying to associate with the bulletin post. Check the value of the `contentDetails.bulletinPosted.videoId` property. |\n| `userRateLimitExceeded (403)` | `rateLimitExceeded` | The request cannot be completed because you have exceeded your [quota](/youtube/v3/getting-started#quota). |"]]