YouTube API:如何获取 liveChatId? [英] YouTube API: How do I get the liveChatId?

查看:33
本文介绍了YouTube API:如何获取 liveChatId?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档说:

liveChatId 参数指定将返回其消息的聊天 ID.与广播关联的实时聊天 ID 在 liveBroadcast 资源的 snippet.liveChatId 属性中返回."

"The liveChatId parameter specifies the ID of the chat whose messages will be returned. The live chat ID associated with a broadcast is returned in the liveBroadcast resource's snippet.liveChatId property."

但是当使用 APIs Explorer 和 youtube.liveBroadcasts.list 获取 liveBroadcast 的片段时,返回的结果中没有 liveChatId 属性.

But when using APIs Explorer and youtube.liveBroadcasts.list to get a liveBroadcast's snippet, there is no liveChatId property on the returned result.

我正在使用以下 URI(省略键):

I'm using the following URI (key omitted):

https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet&mine=true

我做错了什么?

这是响应(一些值替换为...):

Here is the response (some values replaced with ...):

{
 "kind": "youtube#liveBroadcastListResponse",
 "etag": "...",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#liveBroadcast",
   "etag": "...",
   "id": "...",
   "snippet": {
    "publishedAt": "2016-04-18T17:04:24.000Z",
    "channelId": "...",
    "title": "...",
    "description": "...",
    "thumbnails": {
     "default": {
      "url": "...",
      "width": 120,
      "height": 90
     },
     "medium": {
      "url": "...",
      "width": 320,
      "height": 180
     },
     "high": {
      "url": "...",
      "width": 480,
      "height": 360
     },
     "standard": {
      "url": "...",
      "width": 640,
      "height": 480
     },
     "maxres": {
      "url": "...",
      "width": 1280,
      "height": 720
     }
    },
    "scheduledStartTime": "1970-01-01T00:00:00.000Z",
    "actualStartTime": "2016-04-18T17:04:24.250Z",
    "isDefaultBroadcast": false
   }
  }
 ]
}

在请求时,流上还有一个活跃的对话.

There is also an active conversation happening on the stream at the time of the request.

显然,使用立即直播"创建的直播不包含 liveChatId,即使它们包含实时聊天.

Apparently, live broadcasts created using "Stream now" do not contain a liveChatId even though they contain a live chat.

有没有办法获取立即直播"直播的 liveChatId?

Is there a way to get the liveChatId for a "Stream now" live broadcast?

推荐答案

这是一篇相当古老的帖子,但看到我在互联网上搜索了所有答案却找不到答案,我希望有人觉得这有帮助.

this is a rather old post, but seeing as I searched all over the internet for an answer and could not find one, I hope someone finds this helpful.

要获取不属于您的实时活动的 liveChatId,您可以执行以下操作:

To get the liveChatId of a live event that is not yours you can do something like the following:

首先获取videoId

first, get the videoId

response.items[0].id.videoId

然后获取 liveStreamingDetails

Then get the liveStreamingDetails

buildApiRequest('GET',
        '/youtube/v3/videos', {
            'id': videoID,
            'part': 'snippet,contentDetails,statistics,liveStreamingDetails'
        });

现在您可以通过以下方式从上面的响应中获取 liveChatId:

Now you can get the liveChatId from the response above via:

response.items[0].liveStreamingDetails.activeLiveChatId

这篇关于YouTube API:如何获取 liveChatId?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆