如何使用YouTube数据API v3更改页面结果
问题描述:
我正在尝试使用以下示例从YouTube API(v3)获取视频数据:
I'm trying to get video data from the YouTube API (v3) using this example:
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}