【发布时间】:2018-12-03 09:40:19
【问题描述】:
我正在尝试使用 Google Apps 脚本创建一个程序,该程序会在某个 YouTube 频道上传时插入评论。我已经能够从频道中获取最新的 YouTube 视频 ID,但是当我尝试插入评论时,它会引发错误“解析错误(第 19 行,文件'代码')”。
第 19 行:YouTube.CommentThreads.insert("snippet", {
这是我的代码:
function getVideo() {
// MrBeast Channel ID: UCX6OQ3DkcsbYNE6H8uQQuVA
var channel = "UCX6OQ3DkcsbYNE6H8uQQuVA";
var fttx = "FIRST!";
var results = YouTube.Channels.list("contentDetails", {"id": channel});
for (var i in results.items) {
var item = results.items[i];
var playlistId = item.contentDetails.relatedPlaylists.uploads;
// Uploads Playlist ID: UUX6OQ3DkcsbYNE6H8uQQuVA
var playlistResponse = YouTube.PlaylistItems.list("snippet", {"playlistId": playlistId, "maxResults": 1});
for (var j = 0; j < playlistResponse.items.length; j++) {
var playlistItem = playlistResponse.items[j];
var latvid = playlistItem.snippet.resourceId.videoId;
comment(latvid, channel, fttx);
}
}
}
function comment(vid, ytch, fc) {
YouTube.CommentThreads.insert("snippet", {
"snippet.channelId": ytch,
"snippet.videoId": vid,
"snippet.topLevelComment.snippet.textOriginal": fc
});
}
【问题讨论】:
-
第 19 行是什么?
-
@noogui 刚刚添加了第 19 行的内容。再次检查问题。
标签: google-apps-script youtube-data-api