如何从 YouTube V3 api 中检索 URL 值?

How to retrieve the URL value from the YouTube V3 api?

我正在尝试使用 V3 搜索 API (https://www.googleapis.com/youtube/v3/search) 检索有关 YouTube 视频的详细信息。我在 JSON 回复中获取了视频的所有详细信息,但没有获取视频的 URL。有人可以帮助我如何检索 URL 吗?提前致谢。

JSON中没有视频url,需要使用videoId。

例如你有这样的结果:

{
 "kind": "youtube#searchListResponse",
 "etag": "\"F9iA7pnxqNgrkOutjQAa9F2k8HY/KciEh2k6bPhgTexCFr55nrDyEuo\"",
 "nextPageToken": "CAUQAA",
 "pageInfo": {
  "totalResults": 1031,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#searchResult",
   "etag": "\"F9iA7pnxqNgrkOutjQAa9F2k8HY/1Y85a6l1YSEQprOw66ptMsh0Bzw\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "KG0vtEsiPgs"
   },
   "snippet": {
    "publishedAt": "2015-01-04T20:06:53.000Z",
    "channelId": "UC5nc_ZtjKW1htCVZVRxlQAQ",
    "title": "Real Slow - You Flow",
    "description": "That little vocal snippet has got me hooked :) Download... http://bit.ly/1xHDPlX Real Slow https://soundcloud.com/realslowbeats ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/KG0vtEsiPgs/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/KG0vtEsiPgs/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/KG0vtEsiPgs/hqdefault.jpg"
     }
    },
    "channelTitle": "MrSuicideSheep",
    "liveBroadcastContent": "none"
   }
  },
  {

然后您可以提取 videoId 以创建 url 到 link YouTube 视频。

例如items[0].id.videoId给我KG0vtEsiPgs

然后您需要将 videoId 与此 url https://www.youtube.com/watch?v=:

连接起来

https://www.youtube.com/watch?v='videoId'

然后你就有了视频 link。