【问题标题】:Is possible to know the permission in a folder in google docs api可以知道 google docs api 文件夹中的权限
【发布时间】:2012-03-07 14:54:12
【问题描述】:

我只是想知道是否可以获得用户在文件夹或共享文件夹中的权限,

我正在使用这个 url 获取文件夹

  "https://docs.google.com/feeds/default/private/full/-/folder"

但是我怎样才能获得带有 DocumentListEntry 条目对象的文件夹的权限呢?

这是我的代码:

                 query = new DocumentQuery(new URL(
        "https://docs.google.com/feeds/default/private/full/-/folder"));

                    feed = client.getFeed(query, DocumentListFeed.class);
        // Create a new list of tags with the values of google docs
        for (DocumentListEntry entry : feed.getEntries()) {
                    entry.getCanEdit() // this always return true even if i don't have permission in the folder

                    }

我希望有人能帮助我,在此先感谢。

【问题讨论】:

    标签: api google-docs google-apps google-docs-api


    【解决方案1】:

    在 DocsList API 中,您拥有类 Folder,该类具有以下方法:getEditors()getOwners()getViewers();他们每个人都返回一个用户数组。

    现在我认为您无法通过 URL 获取实际的文件夹对象,但您可以使用:getFolderById() 方法。

    这是一个简单的例子:

    1. 首先你需要知道文件夹的ID是什么,至少有三种方法,但最简单的方法是在Google Docs中点击实际文件夹并分析它的URL:

      https://docs.google.com/a/appsbroker.com/?tab=mo#folders/0B7_GXypCeAAdYmM1ZjJjYzktMWM1OS00ZDBiLTk5MDQtNjhiY2U4Zjc2YjZk

      在上面的例子中,文件夹Id是:

      0B7_GXypCeAAdYmM1ZjJjYzktMWM1OS00ZDBiLTk5MDQtNjhiY2U4Zjc2YjZk

    2. 之后你可以编写一个简单的脚本:

      function myFunction() {
          //replace ... with your folder id
          var folder = DocsList.getFolderById("...");
          var owner = folder.getOwner();
          var editors = folder.getEditors();
          var viewers = folder.getViewers();
          //add code to go through the arrays and display them
      }
      

    【讨论】:

    • 谢谢你的回答,但我正在获取与用户帐户关联的所有文件夹,以及你所说的 getOwner();getEditors();getViewers(); 方法,不会出现在DocumentListEntry 条目。
    猜你喜欢
    • 1970-01-01
    • 2011-10-15
    • 1970-01-01
    • 1970-01-01
    • 2020-09-19
    • 2016-06-16
    • 1970-01-01
    • 2013-08-25
    • 1970-01-01
    相关资源
    最近更新 更多