我已设法安排google应用程序脚本文档中提供的示例代码;从我关联的YouTube频道中检索数据。
function myFunction() {
var channelId ={MY ASSOCIATED CHANNEL ID};
// Set the dates for our report
var today = new Date();
var oneMonthAgo = new Date();
oneMonthAgo.setMonth(today.getMonth() - 1);
var todayFormatted = Utilities.formatDate(today, 'UTC', 'yyyy-MM-dd')
var oneMonthAgoFormatted = Utilities.formatDate(oneMonthAgo, 'UTC', 'yyyy-MM-dd');
//query
var analyticsResponse = YouTubeAnalytics.Reports.query(
'channel==' + channelId,
oneMonthAgoFormatted,
todayFormatted,
'views,likes,dislikes,shares',
{
dimensions: 'day',
sort: '-day'
});
//output
Logger.log(analyticsResponse)
}
我不确定如何将脚本验证到我的相关频道。
请帮助您更正代码。
谢谢,
Aneesh
答案 0 :(得分:1)
PS:请确保您使用的是与该频道相关联的Gmail帐户所拥有的脚本。