频道的所有视频时未定义

频道的所有视频时未定义

本文介绍了列出 Youtube 频道的所有视频时未定义 nextPageToken (API v3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我几乎一步一步地按照这个示例为特定的 Youtube 频道生成了所有上传的列表:https://developers.google.com/youtube/v3/code_samples/javascript#my_uploads

I've followed this example nearly step by step for generating a list of all uploads for a specific Youtube channel: https://developers.google.com/youtube/v3/code_samples/javascript#my_uploads

我对代码所做的唯一更改是设置:

The only change I've made to the code is to set this:

var request = gapi.client.youtube.channels.list({
mine: '',

到:

var request = gapi.client.youtube.channels.list({
mine: 'true',

根据 channels.list 方法的文档.

使用 Firebug 控制台时出现此错误:

When using Firebug console I get this error:

response.result is undefined:
nextPageToken = response.result.nextPageToken;

我通过 Google 的 API 资源管理器检查并注意到,虽然响应成功,但 pageInfo 返回为:

I checked via Google's API explorer and noticed that while the response was successful, pageInfo returned as:

"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},

并且 nextPageTokenprevPageToken 不在响应正文中.这似乎很奇怪,因为该频道上传了近 1,500 个视频......

and that nextPageToken and prevPageToken are not present in the response body. This seems odd as there are nearly 1,500 videos uploaded to this channel...

任何想法如何解决这个问题?

Any ideas how to resolve this issue?

推荐答案

此处的代码示例 https://developers.google.com/youtube/v3/code_samples/javascript#my_uploads 使用:

Code example here https://developers.google.com/youtube/v3/code_samples/javascript#my_uploads uses:

playlistId = response.result.items[0].contentDetails.uploads;

获取播放列表ID.查看响应正文,意识到它需要一个额外的级别:

to get the playlistID. Looking over the response body, realized it needed one extra level:

playlistId = response.result.items[0].contentDetails.relatedPlaylists.uploads;

这篇关于列出 Youtube 频道的所有视频时未定义 nextPageToken (API v3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:36