youtube-v3-api频道列表错误

时间:2015-09-20 05:19:49

标签: youtube-api youtube-data-api youtube-channels

当我使用页面https://developers.google.com/youtube/v3/docs/channels/list上的测试表单来获取我的上传ID时,我没有在输出中获得上传ID信息。

200 OK
- HIDE HEADERS -
cache-control:  private, max-age=0, must-revalidate, no-transform
content-encoding:  gzip
content-length:  184
content-type:  application/json; charset=UTF-8
date:  Sun, 20 Sep 2015 05:09:05 GMT
etag:  "jOXstHOM20qemPbHbyzf7ztZ7rI/Z9n3n2b5RwRnE9WNo9TXpCBWbY4"
expires:  Sun, 20 Sep 2015 05:09:05 GMT
server:  GSE
vary:  Origin, X-Origin
{
 "kind": "youtube#channelListResponse",
 "etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/Z9n3n2b5RwRnE9WNo9TXpCBWbY4\"",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 5
 },
 "items": [
 ]
}

用于生成此请求的命令是

GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=StraconisChannel

让我感到困惑的部分是我正在做的事与我正在关注的教程所做的一样,我唯一要改变的是频道名称和使用我的频道名称。他的输出看起来像这样:

200 OK
- HIDE HEADERS -
cache-control:  private, max-age=0, must-revalidate, no-transform
content-encoding:  gzip
content-length:  350
content-type:  application/json; charset=UTF-8
date:  Sun, 20 Sep 2015 05:15:54 GMT
etag:  "jOXstHOM20qemPbHbyzf7ztZ7rI/ih1aNGvKXcChCR4os4iGDwWDjmQ"
expires:  Sun, 20 Sep 2015 05:15:54 GMT
server:  GSE
vary:  Origin, X-Origin
{
 "kind": "youtube#channelListResponse",
 "etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/ih1aNGvKXcChCR4os4iGDwWDjmQ\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 5
 },
 "items": [
  {

   "kind": "youtube#channel",
   "etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/vDeq-1ACEYq89nbPsEZtYt0KNW0\"",
   "id": "UC29ju8bIPH5as8OGnQzwJyA",
   "contentDetails": {
    "relatedPlaylists": {
     "likes": "LL29ju8bIPH5as8OGnQzwJyA",
     "favorites": "FL29ju8bIPH5as8OGnQzwJyA",
     "uploads": "UU29ju8bIPH5as8OGnQzwJyA"
    },
    "googlePlusUserId": "111890735795696959293"
   }
  }
 ]
}

用于结果的请求:

GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=techguyweb

我使用OAuth 2.0激活了授权,所以我不确定是什么问题。

修改

评论说明是因为它是我的YouTube用户名而不是我的Google +帐户名。我忘了把它放在提供的信息中。结果相同。

200 OK
- HIDE HEADERS -
cache-control:  private, max-age=0, must-revalidate, no-transform
content-encoding:  gzip
content-length:  184
content-type:  application/json; charset=UTF-8
date:  Sun, 20 Sep 2015 14:10:14 GMT
etag:  "jOXstHOM20qemPbHbyzf7ztZ7rI/Z9n3n2b5RwRnE9WNo9TXpCBWbY4"
expires:  Sun, 20 Sep 2015 14:10:14 GMT
server:  GSE
vary:  Origin, X-Origin
{
 "kind": "youtube#channelListResponse",
 "etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/Z9n3n2b5RwRnE9WNo9TXpCBWbY4\"",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 5
 },
 "items": [
 ]
}

1 个答案:

答案 0 :(得分:0)

如果您指定了通道ID而不是通道名称,它会返回正确的响应(我通过HTTP请求获取了信息,但它对于您尝试获取响应的方式应该相同)。

{
 "kind": "youtube#channelListResponse",
 "etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/pZlhvAUywQ74J9YlQvQ1UqIqanc\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": "\"jOXstHOM20qemPbHbyzf7ztZ7rI/iPoXCMXPqVZgATwZUSDCg0QqeCM\"",
   "id": "UCoyAhNWQms1nSgGbI3rVebQ",
   "snippet": {
    "title": "StraconisChannel",
    "description": "",
    "publishedAt": "2015-09-08T22:33:23.000Z",
    "thumbnails": {
     "default": {
      "url": "https://yt3.ggpht.com/-Yyqu34zJ9zs/AAAAAAAAAAI/AAAAAAAAAAA/tjDa1pW2Smw/s88-c-k-no/photo.jpg"
     },
     "medium": {
      "url": "https://yt3.ggpht.com/-Yyqu34zJ9zs/AAAAAAAAAAI/AAAAAAAAAAA/tjDa1pW2Smw/s240-c-k-no/photo.jpg"
     },
     "high": {
      "url": "https://yt3.ggpht.com/-Yyqu34zJ9zs/AAAAAAAAAAI/AAAAAAAAAAA/tjDa1pW2Smw/s240-c-k-no/photo.jpg"
     }
    },
    "localized": {
     "title": "StraconisChannel",
     "description": ""
    },
    "country": "US"
   },
   "contentDetails": {
    "relatedPlaylists": {
     "uploads": "UUoyAhNWQms1nSgGbI3rVebQ"
    },
    "googlePlusUserId": "108236998864115482919"
   }
  }
 ]
}

确保您已验证自己的YouTube频道并将频道与Google+信息页或个人资料相关联。