YouTube 数据 API (v3) 搜索分页,返回"items"空



API请求,使用的参数:

["项目" OK]

part = id

channelId = ucxa5vfvvndlgutinga9jmu3a

key = [api键]

maxResults = 50

pageToken = cikceae

响应json:

{
 "kind": "youtube#searchListResponse",
 "etag": ""Bdx4f4ps3xCOOo1WZ91nTLkRZ_c/fRLRzDJR1r68v6VuXm7NWw28YHw"",
 "nextPageToken": "CIkCEAA",
 "prevPageToken": "CNcBEAE",
 "regionCode": "BR",
 "pageInfo": {
  "totalResults": 335,
  "resultsPerPage": 50
 },
 "items": [
  {
   "kind": "youtube#searchResult",
   "etag": ""Bdx4f4ps3xCOOo1WZ91nTLkRZ_c/88OMvV6T3kqFzrIZjG-5CBCAyEM"",
   "id": {
    "kind": "youtube#video",
    "videoId": "gf-L6JkFXjA"
   }
  },
  {
   "kind": "youtube#searchResult",
   "etag": ""Bdx4f4ps3xCOOo1WZ91nTLkRZ_c/XNCA6m3Cej2vCZXp6ad_XdO-RRU"",
   "id": {
    "kind": "youtube#video",
    "videoId": "2wVzOw13t0Q"
  }
  }
 ]
}

返回确定,检查参数存在" nextpagetoken",以获取下一页:

新请求参数:

["项目"空]

part = id

channelId = ucxa5vfvvndlgutinga9jmu3a

key = [api键]

maxResults = 50

pageToken = cikceaa

响应json:

{
 "kind": "youtube#searchListResponse",
 "etag": ""Bdx4f4ps3xCOOo1WZ91nTLkRZ_c/SgHCPDU8UCvUHeC9Mc-IXFn8mrA"",
 "nextPageToken": "CLsCEAA",
 "prevPageToken": "CIkCEAE",
 "regionCode": "BR",
 "pageInfo": {
  "totalResults": 335,
  "resultsPerPage": 50
 },
 "items": []
}

在线测试开发人员.google.com:

"items" OK -> https://developers.google.com/youtube/v3/docs/search/list?apix_params={%22part%22:%22id%22,%22channelId%22:%22UCxA5VFvNdlGUTingA9jMu3A%22,%22maxResults%22:50,%22pageToken%22:%22CIkCEAE%22}
"items" Empty -> https://developers.google.com/youtube/v3/docs/search/list?apix_params={%22part%22:%22id%22,%22channelId%22:%22UCxA5VFvNdlGUTingA9jMu3A%22,%22maxResults%22:50,%22pageToken%22:%22CIkCEAA%22}

***未使用的凭据Google OAuth 2.0

YouTube官方文档的演示功能可能出现问题。

如果您在Google API Explorer中尝试了相同的请求,则将在下一个/上页中获取项目。

n.b我面临着YouTube官方中的类似情况 文档页面不起作用,但是,通过测试相同的请求 Google Data API,它可以按预期工作。

我的建议是,下次您面临类似情况时,请在这些地方尝试:

  • 在YouTube官方Democumentation页面中测试您的请求。
  • 在Google API Explorer中测试您的请求。
  • 在您的网站,API,页面等中测试您的请求。

示例 - 使用给定的channel_id UCxA5VFvNdlGUTingA9jMu3A

的第1页
  • url: https://www.googleapis.com/youtube/v3/search?part=id%2C+snippet&channelId=UCxA5VFvNdlGUTingA9jMu3A&maxResults=50&fields=items(id%2Csnippet(channelId%2CchannelTitle%2Cdescription%2CpublishedAt%2Ctitle))%2Ckind%2CnextPageToken%2CpageInfo%2CprevPageToken%2CregionCode%2CtokenPagination&key={YOUR_API_KEY}
  • 第1页 - Google API Explorer中的链接演示。
  • 第1页的结果:

{
 "kind": "youtube#searchListResponse",
 "nextPageToken": "CDIQAA",
 "regionCode": "CO",
 "pageInfo": {
  "totalResults": 335,
  "resultsPerPage": 50
 },
 "items": [
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "Qq5e5EJjeVo"
   },
   "snippet": {
    "publishedAt": "2017-08-06T21:03:15.000Z",
    "channelId": "UCxA5VFvNdlGUTingA9jMu3A",
    "title": "PART3 vs LUDERKING DESGRADIUS FROG VS MACHINE GENEX Yu-gi-oh Duel Links",
    "description": "JOGO 1- https://www.youtube.com/watch?v=PGV0B6WzFv8&t=432s JOGO 2-https://www.youtube.com/watch?v=DWgIJzQCAaU JOGO 3 NO CANAL DO ...",
    "channelTitle": "Miguel Joker Duelinks"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "Mw-OO_OVIcE"
   },
   "snippet": {
    "publishedAt": "2018-07-08T17:29:53.000Z",
    "channelId": "UCxA5VFvNdlGUTingA9jMu3A",
    "title": "ANALISE NOVO PACK/ ANALISING NEW PACK Yu-gi-oh Duel Links",
    "description": "LINK DO LOOTS/SUPER CHAT GRATIS-https://loots.com/en/tip-jars/migueljoker LINK DO NOSSO DISCORD/OUR FREE DISCORD https://discord.gg/ycdzdsD ...",
    "channelTitle": "Miguel Joker Duelinks"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "zYWvmqyqj3k"
   },
   "snippet": {
    "publishedAt": "2019-04-03T13:53:33.000Z",
    "channelId": "UCxA5VFvNdlGUTingA9jMu3A",
    "title": "Tudo Sobre Misstiming!! Nao perca para Ag Nem Yubel!! Yu-gi-oh Duel Links",
    "description": "Ajude o Canal com Paypal- migueljokerduelinks@gmail.com Manahen Canal ...",
    "channelTitle": "Miguel Joker Duelinks"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "HMlCUz25NsU"
   },
   "snippet": {
    "publishedAt": "2019-02-16T03:08:45.000Z",
    "channelId": "UCxA5VFvNdlGUTingA9jMu3A",
    "title": "TOP 1 KC GLOBAL/ Back to Worlds? De Volta ao Mundial? Yu-gi-oh Duel Links",
    "description": "Pagina Facebook- https://www.facebook.com/migueljokerduelinks/ Latino America- https://www.facebook.com/groups/340304503003946/ LINK DO ...",
    "channelTitle": "Miguel Joker Duelinks"
   }
  },
  [more videos here...],
 ]
}

  • URL-第2页(使用pageToken(:https://www.googleapis.com/youtube/v3/search?part=id%2C+snippet&channelId=UCxA5VFvNdlGUTingA9jMu3A&maxResults=50&fields=items(id%2Csnippet(channelId%2CchannelTitle%2Cdescription%2CpublishedAt%2Ctitle))%2Ckind%2CnextPageToken%2CpageInfo%2CprevPageToken%2CregionCode%2CtokenPagination&key={YOUR_API_KEY}
  • 第2页 - Google API Explorer中的链接演示。
  • 第2页的结果:

{
 "kind": "youtube#searchListResponse",
 "nextPageToken": "CGQQAA",
 "prevPageToken": "CDIQAQ",
 "regionCode": "CO",
 "pageInfo": {
  "totalResults": 335,
  "resultsPerPage": 50
 },
 "items": [
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "LEMjPqqWvy8"
   },
   "snippet": {
    "publishedAt": "2019-05-28T10:57:47.000Z",
    "channelId": "UCxA5VFvNdlGUTingA9jMu3A",
    "title": "Six Samurai Ainda Forte!! Yu-gi-oh Duel Links",
    "description": "Ajude o Canal com Paypal- migueljokerduelinks@gmail.com Manahen Canal ...",
    "channelTitle": "Miguel Joker Duelinks"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "UZXQa3SSy5M"
   },
   "snippet": {
    "publishedAt": "2019-02-22T23:13:05.000Z",
    "channelId": "UCxA5VFvNdlGUTingA9jMu3A",
    "title": "Novo Deck Fenix Bom ou Bosta? New Fenix is it worth it?Yu-gi-oh Duel Links",
    "description": "Pagina Facebook- https://www.facebook.com/migueljokerduelinks/ Latino America- https://www.facebook.com/groups/340304503003946/ LINK DO ...",
    "channelTitle": "Miguel Joker Duelinks"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "lNDxWeFgOYI"
   },
   "snippet": {
    "publishedAt": "2019-04-06T15:13:45.000Z",
    "channelId": "UCxA5VFvNdlGUTingA9jMu3A",
    "title": "Melhor Counter de Six Sams!! Best Six Sam  Counter!! Yu-gi-oh Duel Links",
    "description": "Ajude o Canal com Paypal- migueljokerduelinks@gmail.com Manahen Canal ...",
    "channelTitle": "Miguel Joker Duelinks"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "OP9JTktNEhg"
   },
   "snippet": {
    "publishedAt": "2019-03-02T01:03:24.000Z",
    "channelId": "UCxA5VFvNdlGUTingA9jMu3A",
    "title": "Last  Gamble Cancer Kog Dia1!! 100% Vitoria vs Koaki!! Yu-gi-oh Duel Links",
    "description": "AJ- CANAL https://www.youtube.com/channel/UCZaEOV0fMJBEamZ8K-jPE3A Pagina Facebook- https://www.facebook.com/migueljokerduelinks/ Latino ...",
    "channelTitle": "Miguel Joker Duelinks"
   }
  },
  [more videos here...],
 ]
}

相关内容

  • 没有找到相关文章

最新更新