LiveChatMessages: insert
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
실시간 채팅에 메시지 또는 설문조사를 추가합니다.
일반적인 사용 사례
요청
HTTP 요청
POST https://www.googleapis.com/youtube/v3/liveChat/messages
승인
이 요청에는 다음 범위 중 하나 이상에 대한 승인이 필요합니다. 인증 및 승인에 대해 자세히 알아보려면 OAuth 2.0 인증 구현을 참고하세요.
범위 |
https://www.googleapis.com/auth/youtube |
https://www.googleapis.com/auth/youtube.force-ssl |
매개변수
다음 표에는 이 쿼리가 지원하는 매개변수가 나와 있습니다. 나열된 모든 매개변수는 쿼리 매개변수입니다.
매개변수 |
필수 매개변수 |
part |
string
part 매개변수는 두 가지 목적으로 사용됩니다. 쓰기 연산에서 설정하는 속성과 API 응답에서 포함하는 속성을 식별합니다. 매개변수 값을 snippet 로 설정합니다. |
요청 본문
요청 본문에 liveChatMessage 리소스를 제공합니다.
이 리소스의 경우 다음 속성 값을 지정해야 합니다.
snippet.liveChatId
snippet.type
- textMessageEvent
또는 pollEvent
옵션 중 하나를 선택합니다.
- 유형이
textMessageEvent
인 경우 snippet.textMessageDetails.messageText
포함
- 유형이
pollEvent
인 경우 다음 값으로 snippet.pollDetails
을 포함합니다.
snippet.pollDetails.metadata.options.questionText
snippet.pollDetails.metadata.options.optionText
목록 항목은 2개 이상 5개 미만이어야 합니다. 항목은 나열된 순서대로 순차적으로 표시됩니다.
오류
다음 표에는 이 메서드 호출에 대한 응답으로 API에서 반환할 수 있는 오류 메시지가 나와 있습니다. 자세한 내용은 YouTube Live Streaming API - 오류를 참고하세요.
오류 유형 |
오류 세부정보 |
설명 |
forbidden (403) |
forbidden |
지정된 메시지를 만드는 데 필요한 권한이 없습니다. |
forbidden (403) |
liveChatDisabled |
소유자가 지정한 실시간 채팅을 사용 중지했습니다. 즉, 채팅에 메시지를 추가할 수 없습니다. |
forbidden (403) |
liveChatEnded |
지정된 실시간 채팅이 더 이상 진행되지 않습니다. |
invalidValue (400) |
messageTextInvalid |
메시지 텍스트 (snippet.textMessageDetails.messageText )가 유효하지 않습니다. |
notFound (404) |
liveChatNotFound |
API 요청에서 식별된 실시간 채팅이 존재하지 않습니다. 이 오류는 소유자가 채팅을 삭제한 경우에 발생합니다. |
required (400) |
liveChatIdRequired |
liveChatMessage 리소스는 snippet.liveChatId 속성의 값을 포함하고 지정해야 합니다. |
required (400) |
messageTextRequired |
liveChatMessage 리소스는 snippet.textMessageDetails.messageText 속성의 값을 포함하고 지정해야 합니다. |
required (400) |
typeRequired |
liveChatMessage 리소스는 snippet.type 속성의 값을 포함하고 지정해야 합니다. 매개변수 값을 text 로 설정합니다. |
required (400) |
preconditionCheckFailed |
고정된 활성 설문조사가 이미 있습니다. |
rateLimitExceeded |
rateLimitExceeded |
사용자가 특정 기간에 너무 많은 채팅 메시지를 게시했습니다. |
사용해 보기
APIs Explorer를 사용하여 이 API를 호출하고 API 요청 및 응답을 확인합니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-01-02(UTC)
[null,null,["최종 업데이트: 2025-01-02(UTC)"],[],[],null,["# LiveChatMessages: insert\n\nAdds a message or a poll to a live chat.\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/liveChat/messages\n```\n\n### Authorization\n\nThis request requires authorization with at least one of the following scopes. To read more about authentication and authorization, see [Implementing OAuth 2.0 authentication](/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| `part` | `string` The **part** parameter serves two purposes. It identifies the properties that the write operation will set as well as the properties that the API response will include. Set the parameter value to `snippet`. |\n\n### Request body\n\nProvide a [liveChatMessage resource](/youtube/v3/live/docs/liveChatMessages#resource) in the request body.\nFor that resource, you must specify values for these properties\n\n- `snippet.liveChatId`\n- `snippet.type` - choose one of the following options: `textMessageEvent` or `pollEvent`\n- If type is `textMessageEvent`, include `snippet.textMessageDetails.messageText`\n- If type is `pollEvent`, include `snippet.pollDetails` with the following values:\n - `snippet.pollDetails.metadata.options.questionText`\n - List of `snippet.pollDetails.metadata.options.optionText`. You must list at least two items and no more than four items. Items are displayed sequentially in the order they're listed.\n\nResponse\n--------\n\nIf successful, this method returns a [liveChatMessage 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. For more details, see [YouTube Live Streaming API - Errors](/youtube/v3/live/docs/errors).\n\n| Error type | Error detail | Description |\n|----------------------|---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `forbidden (403)` | `forbidden` | You don't have the permissions required to create the specified message. |\n| `forbidden (403)` | `liveChatDisabled` | The specified live chat has been disabled by the owner, which means messages cannot be added to the chat. |\n| `forbidden (403)` | `liveChatEnded` | The specified live chat is no longer live. |\n| `invalidValue (400)` | `messageTextInvalid` | The message text (`snippet.textMessageDetails.messageText`) is not valid. |\n| `notFound (404)` | `liveChatNotFound` | The live chat identified in the API request does not exist. This error occurs if the chat has been deleted by the owner. |\n| `required (400)` | `liveChatIdRequired` | The [liveChatMessage resource](/youtube/v3/live/docs/liveChatMessages#resource) must include and specify a value for the `snippet.liveChatId` property. |\n| `required (400)` | `messageTextRequired` | The [liveChatMessage resource](/youtube/v3/live/docs/liveChatMessages#resource) must include and specify a value for the `snippet.textMessageDetails.messageText` property. |\n| `required (400)` | `typeRequired` | The [liveChatMessage resource](/youtube/v3/live/docs/liveChatMessages#resource) must include and specify a value for the `snippet.type` property. Set the parameter value to `text` |\n| `required (400)` | `preconditionCheckFailed` | A pinned active poll already exists. |\n| `rateLimitExceeded` | `rateLimitExceeded` | The user has posted too many chat messages in a given timeframe. |\n\nTry it!\n-------\n\nUse the APIs Explorer to call this API and see the API request and response."]]