Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.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
Ios 如何使用YouTube API获取频道名称?_Ios_Swift_Youtube_Youtube Api_Youtube Data Api - Fatal编程技术网

Ios 如何使用YouTube API获取频道名称?

Ios 如何使用YouTube API获取频道名称?,ios,swift,youtube,youtube-api,youtube-data-api,Ios,Swift,Youtube,Youtube Api,Youtube Data Api,我想得到一个视频频道的名称,但它给出了播放列表的名称。我当前正在使用此URLvar urlString=”https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&pageToken=\(pageToken)&playlId=PLFgquLnL59alCl\u 2TQvOiD5Vgm1hCaGSI&key=\(apiKey)” 它现在给了我类似的东西 ["items": <__NSArrayI 0x1c0472540

我想得到一个视频频道的名称,但它给出了播放列表的名称。我当前正在使用此URL
var urlString=”https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&pageToken=\(pageToken)&playlId=PLFgquLnL59alCl\u 2TQvOiD5Vgm1hCaGSI&key=\(apiKey)”

它现在给了我类似的东西

["items": <__NSArrayI 0x1c0472540>(
{
    etag = "\"DuHzAJ-eQIiCIp7p4ldoVcVAOeY/Vq7FiiHfUpgAr9yq9YxmBXwSLrE\"";
    id = UExGZ3F1TG5MNTlhbENsXzJUUXZPaUQ1VmdtMWhDYUdTSS4xNDU2QkYwRjk0NkZBOEVD;
    kind = "youtube#playlistItem";
    snippet =     {
        channelId = "UC-9-kyTW8ZkZNDHQJ6FgpwQ";
        channelTitle = Music;
        description = "\U201cThis is America\U201d by Childish Gambino http://smarturl.it/TcIgA\nDirector: Hiro Murai\nProducer: Jason Cole of Doomsday with Ibra Ake and Fam Rothstein of Wolf + Rothstein\ntour tickets and merchandise available at childishgambino.com";
        playlistId = "PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI";
        position = 0;
        publishedAt = "2018-05-18T11:29:31.000Z";
        resourceId =         {
            kind = "youtube#video";
            videoId = VYOjWnS4cMY;
        };
        thumbnails =         {
            default =             {
                height = 90;
                url = "https://i.ytimg.com/vi/VYOjWnS4cMY/default.jpg";
                width = 120;
            };
            high =             {
                height = 360;
                url = "https://i.ytimg.com/vi/VYOjWnS4cMY/hqdefault.jpg";
                width = 480;
            };
            maxres =             {
                height = 720;
                url = "https://i.ytimg.com/vi/VYOjWnS4cMY/maxresdefault.jpg";
                width = 1280;
            };
            medium =             {
                height = 180;
                url = "https://i.ytimg.com/vi/VYOjWnS4cMY/mqdefault.jpg";
                width = 320;
            };
            standard =             {
                height = 480;
                url = "https://i.ytimg.com/vi/VYOjWnS4cMY/sddefault.jpg";
                width = 640;
            };
        };
        title = "Childish Gambino - This Is America (Official Video)";
    };
},
[“项目”:(
{
etag=“\”DuHzAJ-eQIiCIp7p4ldoVcVAOeY/Vq7FiiHfUpgAr9yq9YxmBXwSLrE\”;
id=UEXGZ3F1TG5MNTLHBENSXZJUXZPAUQ1VMDTMWHDYUDTS4XDU2QKYWRJK0NKZBOEVD;
kind=“youtube#播放项目”;
片段={
channelId=“UC-9-KYTW8ZKDHQJ6FGPWQ”;
频道名称=音乐;
description=“\U201cThis is America\U201d由孩子气的甘比诺创作http://smarturl.it/TcIgA\n导演:Hiro Murai\n制作人:世界末日的Jason Cole与Ibra Ake和Wolf+Rothstein的Fam Rothstein\n我们的门票和商品可在childishgambino.com上获得”;
playlId=“plfgqulnl59alcu2tqvoid5vgm1hcagsi”;
位置=0;
publishedAt=“2018-05-18T11:29:31.000Z”;
资源ID={
kind=“youtube#视频”;
videoId=VYOjWnS4cMY;
};
缩略图={
默认值={
高度=90;
url=”https://i.ytimg.com/vi/VYOjWnS4cMY/default.jpg";
宽度=120;
};
高={
高度=360;
url=”https://i.ytimg.com/vi/VYOjWnS4cMY/hqdefault.jpg";
宽度=480;
};
maxres={
高度=720;
url=”https://i.ytimg.com/vi/VYOjWnS4cMY/maxresdefault.jpg";
宽度=1280;
};
中等={
高度=180;
url=”https://i.ytimg.com/vi/VYOjWnS4cMY/mqdefault.jpg";
宽度=320;
};
标准={
高度=480;
url=”https://i.ytimg.com/vi/VYOjWnS4cMY/sddefault.jpg";
宽度=640;
};
};
title=“孩子气的甘比诺——这是美国(官方视频)”;
};
},

正如您所看到的,频道标题是“音乐”。我如何才能获得真正的频道标题?

从任何播放列表或视频中获取频道ID,并使用频道ID和
part='snippet'
进行编辑。结果将包含频道标题和其他详细信息

示例URL:
https://www.googleapis.com/youtube/v3/channels?id=UC_x5XG1OV2P6uZZ5FSM9Ttw&part=snippet&key=API_KEY

答复:

{
 "kind": "youtube#channelListResponse",
 "etag": "\"DuHzAJ-eQIiCIp7p4ldoVcVAOeY/3xuQp_Bnwrc1tW3bBIDi6LxzB7I\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": "\"DuHzAJ-eQIiCIp7p4ldoVcVAOeY/czbu6JihYqowBUI2jn5-PBL7TvY\"",
   "id": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
   "snippet": {
    "title": "Google Developers",
    "description": "The Google Developers channel features talks from events, educational series, best practices, tips, and the latest updates across our products and platforms.",
    "customUrl": "GoogleDevelopers",
    "publishedAt": "2007-08-23T00:34:43.000Z",
    "thumbnails": {
     "default": {
      "url": "https://yt3.ggpht.com/a-/AJLlDp2JcYTd7j-M2CUsBC2zO-p6TVYo0bE8dsS_fw=s88-mo-c-c0xffffffff-rj-k-no",
      "width": 88,
      "height": 88
     },
     "medium": {
      "url": "https://yt3.ggpht.com/a-/AJLlDp2JcYTd7j-M2CUsBC2zO-p6TVYo0bE8dsS_fw=s240-mo-c-c0xffffffff-rj-k-no",
      "width": 240,
      "height": 240
     },
     "high": {
      "url": "https://yt3.ggpht.com/a-/AJLlDp2JcYTd7j-M2CUsBC2zO-p6TVYo0bE8dsS_fw=s800-mo-c-c0xffffffff-rj-k-no",
      "width": 800,
      "height": 800
     }
    },
    "localized": {
     "title": "Google Developers",
     "description": "The Google Developers channel features talks from events, educational series, best practices, tips, and the latest updates across our products and platforms."
    }
   }
  }
 ]
}

从任何播放列表或视频中获取频道ID,并使用频道ID和
part='snippet'
进行编辑。结果将包含频道标题和其他详细信息

示例URL:
https://www.googleapis.com/youtube/v3/channels?id=UC_x5XG1OV2P6uZZ5FSM9Ttw&part=snippet&key=API_KEY

答复:

{
 "kind": "youtube#channelListResponse",
 "etag": "\"DuHzAJ-eQIiCIp7p4ldoVcVAOeY/3xuQp_Bnwrc1tW3bBIDi6LxzB7I\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": "\"DuHzAJ-eQIiCIp7p4ldoVcVAOeY/czbu6JihYqowBUI2jn5-PBL7TvY\"",
   "id": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
   "snippet": {
    "title": "Google Developers",
    "description": "The Google Developers channel features talks from events, educational series, best practices, tips, and the latest updates across our products and platforms.",
    "customUrl": "GoogleDevelopers",
    "publishedAt": "2007-08-23T00:34:43.000Z",
    "thumbnails": {
     "default": {
      "url": "https://yt3.ggpht.com/a-/AJLlDp2JcYTd7j-M2CUsBC2zO-p6TVYo0bE8dsS_fw=s88-mo-c-c0xffffffff-rj-k-no",
      "width": 88,
      "height": 88
     },
     "medium": {
      "url": "https://yt3.ggpht.com/a-/AJLlDp2JcYTd7j-M2CUsBC2zO-p6TVYo0bE8dsS_fw=s240-mo-c-c0xffffffff-rj-k-no",
      "width": 240,
      "height": 240
     },
     "high": {
      "url": "https://yt3.ggpht.com/a-/AJLlDp2JcYTd7j-M2CUsBC2zO-p6TVYo0bE8dsS_fw=s800-mo-c-c0xffffffff-rj-k-no",
      "width": 800,
      "height": 800
     }
    },
    "localized": {
     "title": "Google Developers",
     "description": "The Google Developers channel features talks from events, educational series, best practices, tips, and the latest updates across our products and platforms."
    }
   }
  }
 ]
}