gpt4 book ai didi

google-apps-script - 将可选查询参数添加到使用 Google Drive API 的 Comment Compiler Script

转载 作者:行者123 更新时间:2023-12-02 00:52:19 26 4
gpt4 key购买 nike

问题是使用 Drive API 的 Comments.list 命令只允许从每个文档中提取最近的 20 条评论。请参阅以下链接中的“pageSize”可选参数。

https://developers.google.com/drive/api/v3/reference/comments/list?apix_params=%7B%22fileId%22%3A%221TFUL94BHcBH398TKiK_omkpQSbKBLXmkgKf7Nb3-vXg%22%2C%22pageSize%22%3A100%2C%22fields%22%3A%22 *%22%7D

我想将“pageSize”可选参数增加到 100,因为该数字似乎是使用脚本可以返回的最大评论数。基本上我需要帮助修改我的脚本来解决这个问题。

我之前有脚本时遇到了这个限制:

var theFolder = DriveApp.getFolderById('1LDcOUPkGN9AtcZkkNqokQOHeDkt8AI_n');
var files = theFolder.getFiles();
var AllComments = [];

while (files.hasNext()) {
var file = files.next();
AllComments.push(Drive.Comments.list(file.getId()).items);
}

我认为可以解决我的问题的当前代码如下所示。

var theFolder = DriveApp.getFolderById('1LDcOUPkGN9AtcZkkNqokQOHeDkt8AI_n');
var files = theFolder.getFiles();
var AllComments = [];

while (files.hasNext()) {
var file = files.next();
var pageSize100 = {
pageSize: 100
};
AllComments.push(Drive.Comments.list(file.getId(),pageSize100).items);
}

如果文件夹中的文档单独包含超过 20 条评论,我希望显示来自该单个文档的最多 100 条评论,但只会显示最近的 20 条评论。

最佳答案

Advanced Google Services 的 Drive API 使用 v2。那么,将 pageSize: 100 修改为 maxResults: 100 怎么样?

在 Drive API v3 中,使用了 pageSize。但在 Drive API v2 中,请使用 maxResults

引用资料:

关于google-apps-script - 将可选查询参数添加到使用 Google Drive API 的 Comment Compiler Script,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56677474/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com