【发布时间】:2023-01-27 04:09:37
【问题描述】:
您好,我正在尝试获取品牌帐户的 YouTube 分析。我正在使用 Google Apps 脚本,但现在我遇到的问题是我总是获取 Google 帐户而非品牌帐户的信息。目前我正在使用这段代码。
function retrieveMyUploads() {
var results = YouTube.Channels.list('contentDetails', {mine: true});
for(var i in results.items) {
var item = results.items[i];
// Get the playlist ID, which is nested in contentDetails, as described in the
// Channel resource: https://developers.google.com/youtube/v3/docs/channels
var playlistId = item.contentDetails.relatedPlaylists.uploads;
var nextPageToken = '';
// This loop retrieves a set of playlist items and checks the nextPageToken in the
// response to determine whether the list contains additional items. It repeats that process
// until it has retrieved all of the items in the list.
while (nextPageToken != null) {
var playlistResponse = YouTube.PlaylistItems.list('snippet', {
playlistId: playlistId,
maxResults: 25,
pageToken: nextPageToken
});
for (var j = 0; j < playlistResponse.items.length; j++) {
var playlistItem = playlistResponse.items[j];
Logger.log('[%s] Title: %s',
playlistItem.snippet.resourceId.videoId,
playlistItem.snippet.title);
}
nextPageToken = playlistResponse.nextPageToken;
}
}
}
如果有人可以帮助我获取品牌帐户而不是 Google 帐户的信息,那就太好了。
【问题讨论】:
标签: google-apps-script youtube-data-api youtube-analytics-api