如何使用YouTube数据API v3更改页面结果 [英] How to change page results with YouTube Data API v3

查看:92
本文介绍了如何使用YouTube数据API v3更改页面结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下示例从YouTube API(v3)获取视频数据:

I'm trying to get video data from the YouTube API (v3) using this example:

问题是我不了解如何更改页面结果.例如,此查询给了我25个项目(maxResults = 25),但总结果是->"totalResults":548669.所以这里的主要问题是如何在第2页上移动并接收其他25个结果?

The problem is that I don't understand how to change the page results. For example this query gives me 25 items (maxResults=25) but total results are --> "totalResults": 548669. So the big question here is how to move on page 2 and receive the other 25 results?

推荐答案

如果查看结果,则会在"pageInfo"之后看到"nextPageToken"项.在您的下一个请求中,这需要作为pageToken传递.

If you look at the results, you will see a "nextPageToken" item right after "pageInfo". This needs to be passed as the pageToken on your next request.

因此,如果您调用此api:

So if you make a call to this api:

https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=25&order=relevance&q=site%3Ayoutube.com&topicId=%2Fm%2F02vx4&key={YOUR_API_KEY}

您可以拨打下一页的电话:

You would make a call to this one for the next page:

https://www.googleapis.com/youtube/v3/search?pageToken=CBkQAA&part=snippet&maxResults=25&order=relevance&q=site%3Ayoutube.com&topicId=%2Fm%2F02vx4&key={YOUR_API_KEY}

这篇关于如何使用YouTube数据API v3更改页面结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆