Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用API V3获得香奈儿封面?_Javascript_Jquery_Youtube_Google Api_Youtube Api - Fatal编程技术网

Javascript 如何使用API V3获得香奈儿封面?

Javascript 如何使用API V3获得香奈儿封面?,javascript,jquery,youtube,google-api,youtube-api,Javascript,Jquery,Youtube,Google Api,Youtube Api,我有这个js代码 $.getJSON('https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&id=UCAeWo3hCZSmoEaM-vJyzsfg&key=KEY', function(data) { var chBnrUrl = data.items[0].brandingSettings.image.bannerImageUrl; alert(chBnrUrl); }); 但我不知道

我有这个js代码

$.getJSON('https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&id=UCAeWo3hCZSmoEaM-vJyzsfg&key=KEY', function(data) {
var chBnrUrl = data.items[0].brandingSettings.image.bannerImageUrl;
alert(chBnrUrl);
 });
但我不知道为什么不在警报中获取徽标?

返回一个标记,但并非所有信息都是公开的。某些字段只能为频道所有者返回。您似乎正在使用一个api密钥,该密钥只返回有关频道的公共信息。如果您是通道的所有者,您应该使用oauth2并验证此请求,那么您应该看到所有信息

请求:

获取{YOUR_API_KEY}

答复:

{
 "kind": "youtube#channelListResponse",
 "etag": "\"RmznBCICv9YtgWaaa_nWDIH1_GM/eeWwfxY-1l2O08f8ZaRnNotNxAw\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {


   "kind": "youtube#channel",
   "etag": "\"RmznBCICv9YtgWaaa_nWDIH1_GM/AsC3_c59Ey-DtR_xdRsD6S1QtDg\"",
   "id": "UCAeWo3hCZSmoEaM-vJyzsfg",
   "snippet": {
    "title": "G & Kids Future",
    "description": "• Welcome all the guests channel G & Kids Future! ♥\n\n• G & Kids Future - Youtube channel for children, for girls and boys. This is the channel for all kids searching for entertainment. Enjoy the channel and subscribe to get to the newest updates!\n\n• Thank you for visiting our channel !!!",
    "customUrl": "gkidsfuture92",
    "publishedAt": "2016-01-07T04:47:47.000Z",
    "thumbnails": {
     "default": {
      "url": "https://yt3.ggpht.com/-HBvDBX_Fwjw/AAAAAAAAAAI/AAAAAAAAAAA/aCgthXWsd-g/s88-c-k-no-mo-rj-c0xffffff/photo.jpg",
      "width": 88,
      "height": 88
     },
     "medium": {
      "url": "https://yt3.ggpht.com/-HBvDBX_Fwjw/AAAAAAAAAAI/AAAAAAAAAAA/aCgthXWsd-g/s240-c-k-no-mo-rj-c0xffffff/photo.jpg",
      "width": 240,
      "height": 240
     },
     "high": {
      "url": "https://yt3.ggpht.com/-HBvDBX_Fwjw/AAAAAAAAAAI/AAAAAAAAAAA/aCgthXWsd-g/s800-c-k-no-mo-rj-c0xffffff/photo.jpg",
      "width": 800,
      "height": 800
     }
    },
    "localized": {
     "title": "G & Kids Future",
     "description": "• Welcome all the guests channel G & Kids Future! ♥\n\n• G & Kids Future - Youtube channel for children, for girls and boys. This is the channel for all kids searching for entertainment. Enjoy the channel and subscribe to get to the newest updates!\n\n• Thank you for visiting our channel !!!"
    }
   },
   "statistics": {
    "viewCount": "257607760",
    "commentCount": "0",
    "subscriberCount": "895691",
    "hiddenSubscriberCount": false,
    "videoCount": "150"
   }
  }
 ]
}

您没有看到数据。项[0]。brandingSettings.image.bannerImageUrl;因为brandingSettings不是响应测试的一部分,所以我犯了一个错误,正确的链接是您仍在使用API密钥,因此不会更改它不是公共数据验证您的用户并重试