我們正在更新 Data API,以符合 YouTube 計算 Shorts 觀看次數的方式。
瞭解詳情
Comments: setModerationStatus
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
設定一或多則留言的審核狀態。API 要求必須由與留言相關的頻道或影片的擁有者授權。
配額影響:呼叫此方法的配額費用為 50 個單位。
常見用途
要求
HTTP 要求
POST https://www.googleapis.com/youtube/v3/comments/setModerationStatus
授權
這項要求至少需要以下其中一個範圍的授權 (進一步瞭解驗證和授權)。
範圍 |
https://www.googleapis.com/auth/youtube.force-ssl |
參數
下表列出這項查詢支援的參數。這裡列出的所有參數都是查詢參數。
參數 |
必要參數 |
id |
string
id 參數會指定以逗號分隔的 ID 清單,指出您要更新審核狀態的留言。 |
moderationStatus |
string
指出指定留言的新管理狀態。
可接受的值如下:
heldForReview :將留言標示為等候管理員審查。
published :清除留言並公開顯示。
rejected :拒絕顯示不合適的留言。這麼做也會有效地隱藏所有針對遭拒留言的回覆。
|
選用參數 |
banAuthor |
boolean
如果希望系統自動拒絕留言作者撰寫的任何其他留言,請使用 banAuthor 參數。如要將作者停權,請將參數值設為 true 。
注意:只有在 moderationStatus 參數也設為 rejected 的情況下,這個參數才有效。 |
回應
如果成功,這個方法會傳回 HTTP 204
回應代碼 (No Content
)。
錯誤
下表說明 API 呼叫這個方法時可能會傳回的錯誤訊息。詳情請參閱錯誤訊息說明文件。
試試看!
使用 APIs Explorer 呼叫這個 API,並查看 API 要求和回應。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-04-26 (世界標準時間)。
[null,null,["上次更新時間:2024-04-26 (世界標準時間)。"],[],[],null,["# Comments: setModerationStatus\n\nSets the moderation status of one or more comments. The API request must be authorized by the owner of the channel or video associated with the comments.\n\n**Quota impact:** A call to this method has a [quota cost](/youtube/v3/getting-started#quota) of 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/youtube/v3/comments/setModerationStatus\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.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| `id` | `string` The **id** parameter specifies a comma-separated list of IDs that identify the comments for which you are updating the moderation status. |\n| `moderationStatus` | `string` Identifies the new moderation status of the specified comments. Acceptable values are: - **heldForReview** -- Marks a comment as awaiting review by a moderator. - **published** -- Clears a comment for public display. - **rejected** -- Rejects a comment as being unfit for display. This action also effectively hides all replies to the rejected comment. |\n| **Optional parameters** |||\n| `banAuthor` | `boolean` The **banAuthor** parameter lets you indicate that you want to automatically reject any additional comments written by the comment's author. Set the parameter value to `true` to ban the author. **Note:** This parameter is only valid if the [moderationStatus](#moderationStatus) parameter is also set to `rejected`. |\n\n### Request body\n\nDo not provide a request body when calling this method.\n\nResponse\n--------\n\nIf successful, this method returns an HTTP `204` response code (`No Content`).\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)` | `banWithoutReject` | The `banAuthor` parameter can only be used if the `moderationStatus` parameter value is `rejected`. |\n| `badRequest (400)` | `operationNotSupported` | Comments not based on Google+ offer only limited moderation functionality. |\n| `badRequest (400)` | `processingFailure` | The API server failed to successfully process the request. While this can be a transient error, it usually indicates that the request's input is invalid. |\n| `forbidden (403)` | `forbidden` | The moderation status of one or more comments cannot be set due to insufficient permissions. The request might not be properly authorized. |\n| `notFound (404)` | `commentNotFound` | One or more of the comments that the request is trying to update cannot be found. Check the values of the request's [id](/youtube/v3/docs/comments/setModerationStatus#id) parameter to ensure that they are correct. |\n\nTry it!\n-------\n\nUse the APIs Explorer to call this API and see the API request and response."]]