【问题标题】:Trying to get the ID of a Live Video from Youtube试图从 Youtube 获取直播视频的 ID
【发布时间】:2020-03-25 17:36:19
【问题描述】:

我正在尝试获取 YouTube 在我们上线时生成的视频 ID。我正在尝试将实时视频与我网站上的实时 cmets 小部件链接起来!

我当前的查询字符串是:https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC4fb76SWvttKJ1T6a2g6yIw&eventType=live&key=[YOUR_API_KEY]

{
  "error": {
    "errors": [{
      "domain": "youtube.search",
      "reason": "invalidSearchFilter",
      "message": "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the \u003ccode\u003etype\u003c/code\u003e parameter to \u003ccode\u003evideo\u003c/code\u003e if you set either the \u003ccode\u003eforContentOwner\u003c/code\u003e or \u003ccode\u003eforMine\u003c/code\u003e parameters to \u003ccode\u003etrue\u003c/code\u003e. You must also set the \u003ccode\u003etype\u003c/code\u003e parameter to \u003ccode\u003evideo\u003c/code\u003e if you set a value for the \u003ccode\u003eeventType\u003c/code\u003e, \u003ccode\u003evideoCaption\u003c/code\u003e, \u003ccode\u003evideoCategoryId\u003c/code\u003e, \u003ccode\u003evideoDefinition\u003c/code\u003e, \u003ccode\u003evideoDimension\u003c/code\u003e, \u003ccode\u003evideoDuration\u003c/code\u003e, \u003ccode\u003evideoEmbeddable\u003c/code\u003e, \u003ccode\u003evideoLicense\u003c/code\u003e, \u003ccode\u003evideoSyndicated\u003c/code\u003e, or \u003ccode\u003evideoType\u003c/code\u003e parameters.",
      "locationType": "parameter",
      "location": ""
    }],
    "code": 400,
    "message": "The request contains an invalid combination of search filters and/or restrictions. Note that you must set the \u003ccode\u003etype\u003c/code\u003e parameter to \u003ccode\u003evideo\u003c/code\u003e if you set either the \u003ccode\u003eforContentOwner\u003c/code\u003e or \u003ccode\u003eforMine\u003c/code\u003e parameters to \u003ccode\u003etrue\u003c/code\u003e. You must also set the \u003ccode\u003etype\u003c/code\u003e parameter to \u003ccode\u003evideo\u003c/code\u003e if you set a value for the \u003ccode\u003eeventType\u003c/code\u003e, \u003ccode\u003evideoCaption\u003c/code\u003e, \u003ccode\u003evideoCategoryId\u003c/code\u003e, \u003ccode\u003evideoDefinition\u003c/code\u003e, \u003ccode\u003evideoDimension\u003c/code\u003e, \u003ccode\u003evideoDuration\u003c/code\u003e, \u003ccode\u003evideoEmbeddable\u003c/code\u003e, \u003ccode\u003evideoLicense\u003c/code\u003e, \u003ccode\u003evideoSyndicated\u003c/code\u003e, or \u003ccode\u003evideoType\u003c/code\u003e parameters."
  }
}

【问题讨论】:

    标签: youtube-api google-apis-explorer


    【解决方案1】:

    您必须将 type 参数设置为 video 才能通过 400 错误。所以一个示例 URL 将是:

    https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC4fb76SWvttKJ1T6a2g6yIw&eventType=live&type=video&key=[YOUR_API_KEY]

    说了这么多,我得到了 200 个响应,但项数组为空。所以我也继续与这个问题作斗争。

    【讨论】:

      猜你喜欢
      • 2018-03-12
      • 2016-04-26
      • 2013-09-12
      • 2018-03-28
      • 2017-05-27
      • 2014-12-15
      • 1970-01-01
      • 2016-09-28
      • 2021-04-20
      相关资源
      最近更新 更多