ChannelBanners: insert
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
將頻道橫幅圖片上傳至 YouTube。這個方法代表更新頻道橫幅圖片的三步驟程序中前兩個步驟:
- 呼叫
channelBanners.insert
方法,將二進位圖片資料上傳至 YouTube。圖片的長寬比必須為 16:9,且尺寸至少為 2048 x 1152 像素。建議上傳 2560 x 1440 像素的圖片。 - 從 API 為步驟 1 傳回的回應中,擷取
url
屬性的值。 - 呼叫
channels.update
方法,更新頻道的品牌宣傳元素設定。將 brandingSettings.image.bannerExternalUrl
屬性的值設為在步驟 2 中取得的網址。
這個方法支援媒體上傳功能。上傳的檔案必須符合下列限制:
- 檔案大小上限:6 MB
- 接受的媒體 MIME 類型:
image/jpeg
、image/png
、application/octet-stream
配額影響:呼叫此方法的配額費用為 50 個單位。
要求
HTTP 要求
POST https://www.googleapis.com/upload/youtube/v3/channelBanners/insert
授權
這項要求需要至少具備下列其中一個範圍的授權。如要進一步瞭解驗證和授權,請參閱「實作 OAuth 2.0 授權」。
範圍 |
https://www.googleapis.com/auth/youtube.upload |
https://www.googleapis.com/auth/youtube |
https://www.googleapis.com/auth/youtube.force-ssl |
參數
下表列出這項查詢支援的參數。列出的所有參數都是查詢參數。
參數 |
選用參數 |
onBehalfOfContentOwner |
string
這個參數只能用於適當的授權要求。
注意:這個參數僅供 YouTube 內容合作夥伴使用。
onBehalfOfContentOwner 參數表示要求的授權憑證可識別 YouTube CMS 使用者,該使用者會代表參數值中指定的內容擁有者行事。這個參數適用於擁有及管理多個 YouTube 頻道的 YouTube 內容合作夥伴。這項功能可讓內容擁有者驗證一次,即可存取所有影片和頻道資料,不必為每個頻道提供驗證憑證。使用者驗證的 CMS 帳戶必須連結至指定的 YouTube 內容擁有者。 |
錯誤
下表列出 API 在回應對此方法的呼叫時可能傳回的錯誤訊息。詳情請參閱「YouTube Data API - 錯誤」。
錯誤類型 |
錯誤詳細資料 |
說明 |
badRequest (400) |
bannerAlbumFull |
你的 YouTube 頻道圖片相簿含有過多圖片。如要修正這個問題,請前往 Google 相簿,然後前往相簿頁面,並從相簿中移除部分圖片。 |
badRequest (400) |
mediaBodyRequired |
要求不包含圖片內容。 |
試試看!
使用 APIs Explorer 呼叫此 API,並查看 API 要求和回應。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-21 (世界標準時間)。
[[["容易理解","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-12-21 (世界標準時間)。"],[[["This method allows you to upload a channel banner image to YouTube, which is the initial stage of a three-step process for updating a channel's banner image."],["The image uploaded must adhere to specific constraints, requiring a 16:9 aspect ratio, a minimum resolution of 2048x1152 pixels (recommended 2560x1440), a maximum file size of 6MB, and supported MIME types including `image/jpeg`, `image/png`, and `application/octet-stream`."],["After uploading the image, you need to extract the URL from the API response and use it in the `channels.update` method to set the channel's `bannerExternalUrl`."],["Utilizing this API method will incur a quota cost of 50 units, and it necessitates authorization with one of the specified scopes: `https://www.googleapis.com/auth/youtube.upload`, `https://www.googleapis.com/auth/youtube`, or `https://www.googleapis.com/auth/youtube.force-ssl`."],["The content owner can use the `onBehalfOfContentOwner` optional parameter to make the request, by authenticating with their CMS account, allowing to manage multiple channels."]]],[]]