如何使用Google App脚本列出Google驱动器文件的注释? [英] How to list comments of google drive files using google app script?

查看:88
本文介绍了如何使用Google App脚本列出Google驱动器文件的注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要编写一个非常简单的脚本来检索使用文件ID添加到文件的注释,并将注释存储到活动表
我已经找到了此页面,但是我真的不知道如何获取使用应用程序脚本运行的代码。

I need to write a very simple script for retrieving the comments added to a file using the file ID, and store the comments to the activesheet I have found this page but I don't really know how to get the code running with an app script.

function retrieveComments(fileId, callback) {
var request = gapi.client.drive.comments.list({
'fileId': fileId
});
request.execute(callback);
}    

每次运行代码时,我都会得到此错误:

Every time I run the code I just get this error:

ReferenceError: "gapi" is not defined. (line 2, file "Comment").

任何帮助将不胜感激!

推荐答案

简短答案:

Drive.Comments.list(id)

如何操作:

驱动器是对驱动器api的调用,但这是仍处于实验阶段,在您的脚本中,您需要进入资源>高级Google服务并激活Drive API。您还需要点击末尾的链接还必须在Google Developers Console中启用这些服务。并在那里激活驱动器API。

the how to:
"Drive" is a call to the drive api but this is still experimental, in your script you need to go in "ressources > advanced google services" and activate the Drive API. You also need to follow the link at the end "These services must also be enabled in the Google Developers Console." and activate the drive API there.

下面是一个示例:

您可以对此 Google文档

,然后看看此脚本webapp 来检索所有注释。

Webapp的源代码为此处(在这里有点混乱,因为我使用了两种方法获得Drvie API的支持)

here an example:
you can add a comment to this google document
and then have a look at this script webapp to retrieve all the comments.
the source code of the webapp is here (It's a little mess in there, because I used two differents methods to get the Drvie API to work)

这篇关于如何使用Google App脚本列出Google驱动器文件的注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆