How to embed Youtube live chat with url permanent?

前端 未结 2 1748
终归单人心
终归单人心 2021-01-11 13:18

The embed URL for a channel\'s live stream is:

https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID

and it works but if I want to e

2条回答
  •  情歌与酒
    2021-01-11 13:50

    You should be able to use YouTube Live Streaming API to get the id and use the Live Stream data for any needs you have.

    Indeed, one of the use cases is:

    • Associate video streams and broadcasts.

    On this page, you have a PHP example on how to "Retrieve a channel's video streams". On that code, $streamItem is a LiveStream, which contains the id of the live stream and you can leverage that.

    On a related note, the API also allows you to work with LiveBroadcasts, which contains the reference snippet.liveChatId to link it to LiveChatMessages. The latter would allow you to work with the messages in any format you want too. Perhaps, this would suit your needs better. The previous page with example codes, also has a good example on how to "Retrieve a channel's broadcasts".

    I could copy the codes here, but I think the best working example is well documented on the Reference of the API :)

提交回复
热议问题