Попытка получить идентификатор живого видео с Youtube - PullRequest
0 голосов
/ 25 марта 2020

Я пытаюсь получить идентификатор видео, который генерирует YouTube, когда мы go живем. Я пытаюсь связать живое видео с виджетами комментариев на моем сайте!

Моя текущая строка запроса: 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."
  }
}

1 Ответ

0 голосов
/ 29 марта 2020

Необходимо установить параметр type для видео, чтобы избежать ошибки 400. Таким образом, пример URL будет:

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

Сказав все, что я получаю 200 ответ, но пустой массив элементов. Поэтому я продолжаю бороться с этой проблемой.

...