问题
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