本文介绍了youtube.subscriptions.list (api v3) - nextPageToken 不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的订阅中获取所有频道.但是nextPageToken"不可用.

I'm trying to get all channels from my subscriptions. But the "nextPageToken" isn't available.

响应应包含nextPageToken":

The response should containing "nextPageToken":

(来自developers.google.com - YouTube (v3) - 订阅:列表)

(from developers.google.com - YouTube (v3) - Subscriptions: list)

{
  "kind": "youtube#subscriptionListResponse",
  "etag": etag,
  "nextPageToken": string,
  "prevPageToken": string,
  "pageInfo": {
  "totalResults": integer,
  "resultsPerPage": integer
  },
  "items": [
    subscription Resource
  ]
}

这是我的要求:

GET https://www.googleapis.com/youtube/v3/subscriptions?part=snippet&maxResults=10&mine=true&key={YOUR_API_KEY}

APIs Explorer - YouTube (v3) - Subscriptions.list:

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.subscriptions.list?part=snippet&maxResults=10&mine=true

我的回答:

{
 "kind": "youtube#subscriptionListResponse",
 "etag": "\"XXXXX/XXXXX\"",
 "pageInfo": {
  "totalResults": 115,
  "resultsPerPage": 10
 },
 "items": [
  ...

你能告诉我为什么缺少 nextPageToken 吗?

Can you tell me why the nextPageToken is missing, please?

推荐答案

这是我想出的一个 JS 代码段来生成至少 1024 个 pageTokens,我不能保证它会产生任何有效的超出这个范围的东西,因为我不能找到任何可以为我提供大于 450 的偏移量代币的服务,以验证我的猜测和假设.

Here is a JS snippet I came up with to generate pageTokens up to at least 1024, I cannot guarantee that it will produce anything valid beyond that as i could not find any service which will get me tokens for offsets > 450 to validate my guesses and assumptions.

var d0 = "AEIMQUYcgkosw048";
var d1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var d2 = d1;
var d1c = 0;
var d2c = 0;
var overflowSuffix = "Q";
var direction = "AA";
var d2OverflowCounter = 0;
var pageSize = 50;

for (i = 0; i < 1024; i++) {
  if (i % pageSize == 0) console.log("C" + d1.charAt((d1c / d0.length) % d1.length) + d0.charAt(i % d0.length) + overflowSuffix + direction, ":", i);
  if (++d1c % (1 << 8) == 0) d1c = 1 << 7;
  if (++d2c % (1 << 7) == 0) overflowSuffix = d2.charAt(++d2OverflowCounter) + "E";
}

(检查开发者工具/控制台以查看生成的代码)

(check developer tools / console to see generated codes)

这篇关于youtube.subscriptions.list (api v3) - nextPageToken 不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 07:24