LiveChatMessages: transition
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
转换 YouTube 实时聊天消息的状态,并启动与新状态相关的所有流程。例如,如果您将实时投票的状态转换为 closed
,YouTube 会结束相应消息的投票。在调用此方法之前,您应确认实时投票消息的 status
属性的值为 active
。
请求
HTTP 请求
POST https://www.googleapis.com/youtube/v3/liveChatMessages/transition
授权
此请求需要获得以下至少一个范围的授权(详细了解身份验证和授权)。
范围 |
https://www.googleapis.com/auth/youtube |
https://www.googleapis.com/auth/youtube.force-ssl |
参数
下表列出了此查询支持的参数。列出的所有参数均为查询参数。
参数 |
必需参数 |
id |
string
id 参数用于指定要转换为其他状态的消息的唯一 ID。 |
status |
enum
status 参数用于标识消息要变为哪种状态。如需将消息转换为 closed 状态,消息绑定到的轮询的 status 必须为 active 。
您只能转换到 closed ,这意味着意见调查已关闭。
|
可选参数 |
part |
string
part 参数指定 API 响应将包含的 liveChatMessage 资源部分。支持的值包括 id 、snippet 和 authorDetails 。
将参数值设为 snippet 可在响应正文中获取最终的轮询结果。
|
错误
下表列出了 API 在响应此方法调用时可能会返回的错误消息。如需了解详情,请参阅错误消息文档。
错误类型 |
错误详情 |
说明 |
forbidden (403) |
forbidden |
您没有转换指定邮件状态所需的权限。 |
required (400) |
idRequired |
必需的 id 参数必须标识您想要转换其状态的消息。 |
required (400) |
statusRequired |
API 请求必须指定 status 参数的值。 |
notFound (404) |
liveChatMessagesNotFound |
id 参数指定的消息不存在。 |
forbidden (403) |
modificationNotAllowed |
指定的 liveChatMessage 资源的状态无法转换。id 参数可以标识状态无法转换的消息。 |
试试看!
使用 APIs Explorer 调用此 API 并查看 API 请求和响应。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-08。
[null,null,["最后更新时间 (UTC):2024-08-08。"],[[["\u003cp\u003eThis API endpoint transitions the status of a YouTube live chat message, such as closing an active poll.\u003c/p\u003e\n"],["\u003cp\u003eThe request requires authorization and must include the message's unique \u003ccode\u003eid\u003c/code\u003e and the new \u003ccode\u003estatus\u003c/code\u003e (\u003ccode\u003eclosed\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epart\u003c/code\u003e parameter, which is optional, specifies which parts of the \u003ccode\u003eliveChatMessage\u003c/code\u003e resource to include in the API response (e.g. \u003ccode\u003esnippet\u003c/code\u003e, \u003ccode\u003eid\u003c/code\u003e, \u003ccode\u003eauthorDetails\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eSuccessful calls to this API will return a \u003ccode\u003eliveChatMessages\u003c/code\u003e resource in the response body, detailing the message's new status.\u003c/p\u003e\n"],["\u003cp\u003eCommon errors include \u003ccode\u003eforbidden\u003c/code\u003e for permission issues, \u003ccode\u003erequired\u003c/code\u003e for missing parameters, \u003ccode\u003enotFound\u003c/code\u003e if the message ID doesn't exist, and \u003ccode\u003emodificationNotAllowed\u003c/code\u003e if the specified message's status can't be changed.\u003c/p\u003e\n"]]],["This API endpoint, `liveChatMessages/transition`, changes a YouTube live chat message's status and triggers related actions. It requires the message's `id` and the target `status`, which can only be `closed`. The `status` of the poll must be `active` to proceed with the transition. The request is a `POST` method without a request body. Authorization scopes `youtube` or `youtube.force-ssl` are needed. Upon success, a `liveChatMessages` resource is returned, and errors include `forbidden`, `required`, and `notFound`.\n"],null,["# LiveChatMessages: transition\n\nTransitions the status of a YouTube live chat message and initiates any processes associated with the new status. For example, when you transition a live poll's status to `closed`, YouTube ends that message's poll. Before calling this method, you should confirm that the value of the [status](/youtube/v3/live/docs/liveChatMessages#snippet.pollDetails.metadata.status) property for the live poll message is `active`.\n\nRequest\n-------\n\n### HTTP request\n\n```\nPOST https://www.googleapis.com/youtube/v3/liveChat/messages/transition\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/live/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| `id` | `string` The **id** parameter specifies the unique ID of the message that is transitioning to another status. |\n| `status` | `enum` The **status** parameter identifies the state to which the message is changing. To transition a message to the `closed` state, the [status](/youtube/v3/live/docs/liveChatMessages#snippet.pollDetails.metadata.status) must be `active` for the poll that the message is bound to. \u003cbr /\u003e You can only transition to **closed**, meaning that the poll is closed. |\n| **Optional parameters** |||\n| `part` | `string` The **part** parameter specifies the `liveChatMessage` resource parts that the API response will include. Supported values are `id`, `snippet`, and `authorDetails`. \u003cbr /\u003e Set the parameter value to `snippet` to get the final poll result in the response body. |\n\n### Request body\n\nDo not provide a request body when calling this method.\n\nResponse\n--------\n\nIf successful, this method returns a [liveChatMessages resource](/youtube/v3/live/docs/liveChatMessages#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/live/docs/errors) documentation for more detail.\n\n| Error type | Error detail | Description |\n|-------------------|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `forbidden (403)` | `forbidden` | You don't have the permissions required to transition the status of the specified message. |\n| `required (400)` | `idRequired` | The required `id` parameter must identify the message whose status you want to transition. |\n| `required (400)` | `statusRequired` | The API request must specify a value for the `status` parameter. |\n| `notFound (404)` | `liveChatMessagesNotFound` | The message specified by the `id` parameter does not exist. |\n| `forbidden (403)` | `modificationNotAllowed` | The status of the specified `liveChatMessage` resource cannot be transitioned. The `id` parameter might identify a message whose status cannot be transitioned. |\n\nTry it!\n-------\n\nUse the APIs Explorer to call this API and see the API request and response."]]