Youtube 直播 API liveChatNotFound

Youtube Live Streaming API liveChatNotFound

我正在尝试找到一种方法来从流中获取所有消息,我已经很接近了,但后来我收到了一个错误。出于某种原因,我使用的视频 ID 无效,即使它 有效。也许我弄错了ID?这是 XMLHttpRequest:

https://www.googleapis.com/youtube/v3/liveChat/messages?liveChatId=hHW1oY26kxQ&part=snippet&key={API-KEY}&maxResults=2000

这是回复:

{
 "error": {
  "errors": [
   {
    "domain": "youtube.liveChat",
    "reason": "liveChatNotFound",
    "message": "The live chat that you are trying to retrieve cannot be found. Check the value of the requests \u003ccode\u003eliveChatId\u003c/code\u003e parameter to ensure that it is correct."
   }
  ],
  "code": 404,
  "message": "The live chat that you are trying to retrieve cannot be found. Check the value of the requests \u003ccode\u003eliveChatId\u003c/code\u003e parameter to ensure that it is correct."
 }
}

为以下 api 传递您的 视频 ID 并获取实际的 在线聊天 ID

获取实时聊天 ID(替换为您的 api 密钥)

https://www.googleapis.com/youtube/v3/videos?id=kpfV38Hcnds&key=AIzaxxxxxxxxxxxxxxxxdQShvisQW_kdY0Yxxx&part=liveStreamingDetails

在响应中你会找到 livechatid,将这个 livechatid 传递给下面 api

获取所有聊天记录(替换为您的 api 密钥)

https://www.googleapis.com/youtube/v3/liveChat/messages?liveChatId=Cg0KC2twZlYzOEhjbmRz&part=snippet&key=AIzaxxxxxxxxxxxxxxxxdQShvisQW_kdY0Yxxx