我正在尝试从通过 api key 验证的用户那里获取未列出的视频
https://www.googleapis.com/youtube/v3/search?part=snippet&forMine=true&type=video&maxResults=50&key=keyremoved
我收到错误
"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.",
如您所见,我的 get 请求包含一个 type=video 参数。
当我尝试 https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&forMine=true&maxResults=50&type=video
使用 oauth2 登录 youtube 帐户后,它工作正常
最佳答案
您不能为 forMine
使用 API key 范围。
您需要发送授权的 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
关于api - 通过 php 向 youtube 用户请求未列出的视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36410632/