本文介绍了如何使用 nextPageToken 在一个频道中列出超过 50 个 Youtube 视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下链接,它列出了我的所有视频,最多 50 个结果.

Using the following link, it listed all of my videos up to 50 results.

https://www.googleapis.com/youtube/v3/search?key={your_key_here}&channelId={channel_id_here}&part=snippet,id&order=date&maxResults=50

但是,我想列出我频道中的所有视频,所以我添加了 pageToken 参数(最多 500 个结果).这是我通过在 pageToken=nextPageToken

However, I wanted to list all of my videos in my channel so I added in the pageToken parameter (max 500 results). Here is the link I used by adding this in pageToken=nextPageToken

https://www.googleapis.com/youtube/v3/search?key={your_key_here}&channelId={channel_id_here}&part=snippet,id&order=date&maxResults=50&pageToken=nextPageToken

但是,它给了我以下错误

However, it gave me the following error

{
     "error": {
          "errors": [
           {
                "domain": "youtube.parameter",
                "reason": "invalidPageToken",
                "message": "The request specifies an invalid page token.",
                "locationType": "parameter",
                "location": "pageToken"
           }
          ],
          "code": 400,
          "message": "The request specifies an invalid page token."
     }
}

这应该如何复制,以便实际显示nextPageToken?

How is this supposed to be replicated so it will actually display the nextPageToken?

推荐答案

当您进行搜索时,如果有另一页结果,结果将包含一个 nextPageToken 字段.

When you do a search, the results contain a nextPageToken field if there is another page of results.

{
 "kind": "youtube#searchListResponse",
 "etag": "\"cbz3lIQ2N25AfwNr-BdxUVxJ_QY/jtd94kasKWBOdCB882K5N-sSrnQ\"",
 "nextPageToken": "CAEQAA",
 "regionCode": "US",
 "pageInfo": {
 "totalResults": 1000000,
 "resultsPerPage": 1
},

在下一次搜索调用中设置 pageToken 等于该 nextPageToken 值将返回下一页.

Setting pageToken in your next search call equal to that nextPageToken value will return the next page.

https://www.googleapis.com/youtube/v3/search?...&pageToken=CAEQAA

这篇关于如何使用 nextPageToken 在一个频道中列出超过 50 个 Youtube 视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 08:48