且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取 *** 直播期间通过“聊天"框输入的评论供稿?

更新时间:2023-11-26 22:57:46

现在可以使用 LiveChatMessages 端点,作为 *** 直播 API 的一部分.

It is now possible to return chat messages for your own broadcasts using the LiveChatMessages endpoint as part of the *** Live Streaming API.

当创建一个新的liveBroadcast 对象时,一个liveChatId 字符串将作为该liveBroadcastsnippet的一部分返回代码>.将广播的聊天 ID 传递给 LiveChatMessages/list 端点的 liveChatId 参数,以及 idsnippetauthorDetailspart 参数中.

When creating a new liveBroadcast object, a liveChatId String will be returned as part of that liveBroadcast's snippet. Pass your broadcast's chat ID to LiveChatMessages/list endpoint's liveChatId parameter, and id, snippet, and authorDetails into the part parameter.

HTTP GET https://www.googleapis.com/***/v3/liveChat/messages?liveChatId={liveChatId}&part=id%2C+snippet%2C+authorDetails&key={YOUR_API_KEY}

这将返回一组 liveChatMessage一>资源.实际聊天消息包含在 textMessageDetails 字典中,作为 messageText 键的值.

This will return an array of liveChatMessage resources. The actual chat message is contained in the textMessageDetails dictionary as the value for the messageText key.

"textMessageDetails": {
  "messageText": string
}