【问题标题】:Accessing comments in Google Documents访问 Google 文档中的评论
【发布时间】:2012-07-24 12:24:42
【问题描述】:

我无法弄清楚如何使用 Google Apps 脚本访问 Google 文档中的 cmets。查看 API 参考,我发现只有 CommentSection 类,但它被标记为已弃用。寻求帮助。谢谢。

桑杰

【问题讨论】:

标签: google-apps-script google-docs


【解决方案1】:

在这篇文章的初步讨论之后,我设法通过使用 v2 of Drive API 将 cmets 放入文档中。

这是我正在使用的代码:

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. 脚本项目 - 使用“资源 > 高级 Google 服务”
  2. Google 开发者控制台 - 作者:
    1. 确保在顶部栏中选择正确的项目
    2. 为项目启用“Drive API”

【讨论】:

【解决方案2】:

很遗憾,目前无法使用 Google Apps 脚本访问文档的 cmets。您可以在 issue tracker 上提出功能请求。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2014-04-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-13
  • 1970-01-01
相关资源
最近更新 更多