nextPageToken undefined when listing all videos for a Youtube channel (API v3)

北城以北 提交于 2019-12-11 07:04:13

问题


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: '',

to:

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

per documentation for the channels.list method.

When using Firebug console I get this error:

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

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

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

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?


回答1:


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

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

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

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


来源:https://stackoverflow.com/questions/16720660/nextpagetoken-undefined-when-listing-all-videos-for-a-youtube-channel-api-v3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!