我們正在更新 Data API,以符合 YouTube 計算 Shorts 觀看次數的方式。
瞭解詳情
Thumbnails: set
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
將自訂影片縮圖上傳至 YouTube,並設定影片。
這個方法支援媒體上傳功能。上傳的檔案必須符合下列條件:
- 檔案大小上限:2 MB
- 接受的媒體 MIME 類型:
image/jpeg
、image/png
、application/octet-stream
配額影響:對這個方法的呼叫設有約 50 個單位的配額費用。
常見用途
要求
HTTP 要求
POST https://www.googleapis.com/upload/youtube/v3/thumbnails/set
授權
這項要求需要至少下列其中一個範圍的授權 (進一步瞭解驗證和授權)。
內容範圍 |
https://www.googleapis.com/auth/youtubepartner |
https://www.googleapis.com/auth/youtube.upload |
https://www.googleapis.com/auth/youtube |
https://www.googleapis.com/auth/youtube.force-ssl |
參數
下表列出此查詢支援的參數。這裡列出的參數全都是查詢參數。
參數 |
必要參數 |
videoId |
string
videoId 參數會指定要提供自訂影片縮圖的 YouTube 影片 ID。 |
選用參數 |
onBehalfOfContentOwner |
string
注意:這個參數僅適用於 YouTube 內容合作夥伴。
onBehalfOfContentOwner 參數代表用於要求的授權憑證,代表 YouTube CMS 使用者,代表在參數值中指定的內容擁有者代表行事。這個參數適用於擁有及管理多個不同 YouTube 頻道的 YouTube 內容合作夥伴。內容擁有者只要通過一次驗證,即可存取所有影片和頻道資料,不必分別提供各個頻道的驗證憑證。使用者用來驗證的實際 CMS 帳戶,必須連結至指定的 YouTube 內容擁有者。 |
要求主體
要求內文包含您要上傳的縮圖圖片。要求主體不包含 thumbnail
資源。
回應
如果成功的話,這個方法會傳回回應內文,其結構如下:
{
"kind": "youtube#thumbnailSetResponse",
"etag": etag,
"items": [
thumbnail resource
]
}
屬性
下表定義了這項資源中顯示的屬性:
屬性 |
kind |
string 識別 API 資源的類型。值為 youtube#thumbnailSetResponse 。 |
etag |
etag
這項資源的 Etag。 |
items[] |
list
列出縮圖。 |
錯誤
下表列出 API 回應此方法時可能傳回的錯誤訊息。詳情請參閱錯誤訊息的說明文件。
錯誤類型 |
錯誤詳細資料 |
說明 |
badRequest (400) |
invalidImage |
提供的圖片內容無效。 |
badRequest (400) |
mediaBodyRequired |
這項要求不包含圖片內容。 |
forbidden (403) |
forbidden |
無法為指定的影片設定縮圖。要求可能未獲適當授權。 |
forbidden (403) |
forbidden |
通過驗證的使用者沒有上傳及設定自訂影片縮圖的權限。 |
notFound (404) |
videoNotFound |
找不到你要插入縮圖的影片。檢查要求的 videoId 參數值,確認值正確無誤。 |
tooManyRequests (429) |
uploadRateLimitExceeded |
這個頻道最近上傳了過多縮圖。請稍後再嘗試提出要求。 |
試試看!
使用 APIs Explorer 呼叫這個 API 並查看 API 要求和回應。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-04-26 (世界標準時間)。
[null,null,["上次更新時間:2024-04-26 (世界標準時間)。"],[],[],null,["# Thumbnails: set\n\nUploads a custom video thumbnail to YouTube and sets it for a video.\n\nThis method supports media upload. Uploaded files must conform to these constraints:\n\n- **Maximum file size:** 2MB\n- **Accepted Media MIME types:** `image/jpeg`, `image/png`, `application/octet-stream`\n\n**Quota impact:** A call to this method has a [quota cost](/youtube/v3/getting-started#quota) of approximately 50 units.\n\nCommon use cases\n----------------\n\nThe list below shows common use cases for this method. Hover over a use case to see its description, or click on a use case to load sample parameter values in the APIs Explorer. You can open the [fullscreen APIs Explorer](#) to see code samples that dynamically update to reflect the parameter values entered in the Explorer.\n\nThe table below shows common use cases for this method. You can click on a use case name to load sample parameter values in the APIs Explorer. Or you can see code samples for a use case in the fullscreen APIs Explorer by clicking on the code icon below a use case name. In the fullscreen UI, you can update parameter and property values and the code samples will dynamically update to reflect the values you enter. \nThis method has one common use case, which is described below. The buttons below the description populate the APIs Explorer with sample values or open the fullscreen APIs Explorer to show code samples that use those values. The code samples also dynamically update if you change the values.\n\n\u003cbr /\u003e\n\nRequest\n-------\n\n### HTTP request\n\n```\nPOST https://www.googleapis.com/upload/youtube/v3/thumbnails/set\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/youtubepartner` |\n| `https://www.googleapis.com/auth/youtube.upload` |\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| `videoId` | `string` The **videoId** parameter specifies a YouTube video ID for which the custom video thumbnail is being provided. |\n| **Optional parameters** |||\n| `onBehalfOfContentOwner` | `string` **Note:** This parameter is intended exclusively for YouTube content partners. The **onBehalfOfContentOwner** parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value. This parameter is intended for YouTube content partners that own and manage many different YouTube channels. It allows content owners to authenticate once and get access to all their video and channel data, without having to provide authentication credentials for each individual channel. The actual CMS account that the user authenticates with must be linked to the specified YouTube content owner. |\n\n### Request body\n\nThe body of the request contains the thumbnail image that you are uploading. The request body does not contain a [thumbnail](/youtube/v3/docs/thumbnails#resource-representation) resource.\n\nResponse\n--------\n\nIf successful, this method returns a response body with the following structure: \n\n```objective-c\n{\n \"kind\": \"youtube#thumbnailSetResponse\",\n \"etag\": etag,\n \"items\": [\n thumbnail resource\n ]\n}\n```\n\n### Properties\n\nThe following table defines the properties that appear in this resource:\n\n| Properties ||\n|-----------|------------------------------------------------------------------------------------------------|\n| `kind` | `string` Identifies the API resource's type. The value will be `youtube#thumbnailSetResponse`. |\n| `etag` | `etag` The Etag of this resource. |\n| `items[]` | `list` A list of thumbnails. |\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)` | `invalidImage` | The provided image content is invalid. |\n| `badRequest (400)` | `mediaBodyRequired` | The request does not include the image content. |\n| `forbidden (403)` | `forbidden` | The thumbnail can't be set for the specified video. The request might not be properly authorized. |\n| `forbidden (403)` | `forbidden` | The authenticated user doesn't have permissions to upload and set custom video thumbnails. |\n| `notFound (404)` | `videoNotFound` | The video that you are trying to insert a thumbnail image for cannot be found. Check the value of the request's `videoId` parameter to ensure that it is correct. |\n| `tooManyRequests (429)` | `uploadRateLimitExceeded` | The channel has uploaded too many thumbnails recently. Please try the request again later. |\n\nTry it!\n-------\n\nUse the APIs Explorer to call this API and see the API request and response."]]