我无法弄清楚如何使用Google Apps Scripts访问Google文档中的评论。查看API参考,我发现只有CommentSection类,但标记为已弃用。寻求一些帮助。感谢。
桑杰
答案 0 :(得分:5)
在本文的初步讨论之后,我设法使用v2 of Drive API在文档中获取了评论。
以下是我正在使用的代码:
function retrieveComments(fileId) {
var info = [];
//These arguments are optional
var callArguments = {'maxResults': 100, 'fields': 'items(commentId,content,context/value,fileId),nextPageToken'}
var docComments, pageToken;
do { //Get all the pages of comments in case the doc has more than 100
callArguments['pageToken'] = pageToken;
//This is where the magic happens!
docComments = Drive.Comments.list(fileId,callArguments);
//I've created a "getCommentsInfo" to organize the relevant info in an array
info = info.concat(getCommentsInfo(docComments.items));
pageToken = docComments.nextPageToken;
} while(pageToken);
return(info);
}
但是,由于 Drive API 是“高级服务”,您必须将其添加到:
答案 1 :(得分:0)
不幸的是,目前无法使用Google Apps脚本访问该文档的评论。您可以在issue tracker上为此提交功能请求。