google-api - 如何在 Drive API 中获取 google doc 修订的详细列表

标签 google-api google-drive-api revision-history revisions

我正在尝试找到一种方法来使用 Google Drive API 检索 Google 文档修订的详细列表。我试图用 Java 实现它,它确实返回了 10 个修订的列表。然而,这份 list 还不够详细。如果我转到 Google Drive,打开此文件并通过“文件-查看修订历史记录”检查修订,它将返回与我从 Drive API 获得的相同的列表(10 个修订)。但是有一个名为“显示更详细的修订”的按钮,如果我单击它,它将返回一个详细的修订列表。

有谁知道如何通过 Drive API 获取此详细列表?或者有没有其他替代方法来获得这个详细的修订列表?

最佳答案

您应该同时使用 getlist获取谷歌驱动文件修订详细列表的方法;下面的示例应该可以工作(我还没有测试过):

    /**
       * Print detail information about revisions of the specified file.
       *
       * @param service Drive API service instance.
       * @param fileId ID of the file to print revisions for.
    */
    private static void detailedRevisions(Drive service, String fileId) {
        try {
           RevisionList revisions = service.revisions().list(fileId).execute();
           List<Revision> revisionList = revisions.getItems();

           for(Revision revision : revisionList) {
               revision = service.revisions().get(
                 fileId, revision.getId()).execute();

               System.out.println("Revision ID: " + revision.getId());
               System.out.println("Modified Date: " + revision.getModifiedDate());
               if (revision.getPinned()) {
                   System.out.println("This revision is pinned");
               }
           }
        } catch (IOException e) {
            System.out.println("An error occured: " + e);
        }
    }

检查此以获取 Revision 类方法的完整列表:
https://developers.google.com/resources/api-libraries/documentation/drive/v2/java/latest/

关于google-api - 如何在 Drive API 中获取 google doc 修订的详细列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13107369/

相关文章:

php - 在 Google 日历中插入事件 PHP 和 SQL

git - 审查提交历史

svn - 提交前显示合并历史

git - 删除 git 中的分支是否会将其从历史记录中删除?

android - 来自 React Native 的 Google 服务帐户身份验证

api - YouTube API。检查用户是否已订阅

.net - 带有单引号和反斜杠的 Google Drive Query 问题

c# - 找不到方法 : 'Void Google.Apis.Util.Store.FileDataStore..ctor(System.String)'

javascript - 从node.js googledrive api返回结果

javascript - 如果日期匹配,则通过单个电子邮件发送所有行