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 和/或其關聯企業的註冊商標。
上次更新時間:2024-04-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-04-26 (世界標準時間)。"],[[["YouTube's channel bulletin feature has been deprecated and is no longer supported."],["Creating an activity requires authorization with specific scopes, such as `https://www.googleapis.com/auth/youtube` or `https://www.googleapis.com/auth/youtube.force-ssl`."],["The `part` parameter in the request specifies which properties will be modified and included in the API response, such as `contentDetails`, `id`, and `snippet`."],["The request body must include an activity resource, and it is required to provide a value for `snippet.description`."],["This method call has a quota cost of 50 units, and exceeding the quota will result in a `userRateLimitExceeded` error."]]],["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"]]