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

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

问题描述

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

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

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&maxResults=25&order=relevance&q=site%253Ayoutube.com&topicId=%252Fm%252F02vx4&_h=1&

问题是我不明白如何更改页面结果.例如,这个查询给了我 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 Data API v3 更改页面结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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