Request unlisted videos from youtube user via php

时间:2016-04-04 18:55:05

标签: api video youtube

i'm trying to get unlisted videos from a user authenticated by api key

https://www.googleapis.com/youtube/v3/search?part=snippet&forMine=true&type=video&maxResults=50&key=keyremoved

i receive the error

"error": {
      "errors": [
       {
        "domain": "youtube.search",
        "reason": "invalidSearchFilter",
        "message": "The request contains an invalid combination of search Note that you must 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.",

as you can see my get request contains a type=video parameter.
When i try https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&forMine=true&maxResults=50&type=video
with logged in the youtube account using oauth2 it works fine

1 个答案:

答案 0 :(得分:0)

您无法为forMine参数使用API​​密钥。 您需要发送授权的OAuth2请求才能使用。

$ curl --header "Authorization: Bearer <YOUR_ACCESS_TOKEN>" https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&forMine=true&maxResults=50
{
   "kind": "youtube#searchListResponse",
   "etag": ...

https://developers.google.com/youtube/v3/docs/search/list#forMine