How to obtain a feed of comments entered through the 'chat' box during a YouTube live broadcast?

前端 未结 3 1885
生来不讨喜
生来不讨喜 2020-11-29 03:39

The YouTube API enables users to obtain a comments feed, e.g. via https://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments?orderby=published.

Howeve

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 04:08

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

    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/youtube/v3/liveChat/messages?liveChatId={liveChatId}&part=id%2C+snippet%2C+authorDetails&key={YOUR_API_KEY}
    

    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
    }
    

提交回复
热议问题