【问题标题】:How do I get exportLinks for revisions in Google Drive API如何在 Google Drive API 中获取用于修订的 exportLinks
【发布时间】:2013-06-21 11:30:26
【问题描述】:

我正在使用 Google Apps 脚本尝试为 Google 绘图的各种修订获取导出链接列表。下面的代码重现了该问题。要试用它,请使用绘图 ID 调用 getRevisionHx。

//Google oAuth
function googleOAuth_(name,scope) {
  var oAuthConfig = UrlFetchApp.addOAuthService(name);
  oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
      oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
  oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
  oAuthConfig.setConsumerKey("anonymous");
  oAuthConfig.setConsumerSecret("anonymous");
  return {oAuthServiceName:name, oAuthUseToken:"always"};
}

function getRevisionHx(resource_id){
  var scope = 'https://www.googleapis.com/auth/drive';
  var myKey = KEY_DELETED_FROM_SAMPLE_CODE;

  var fetchArgs = googleOAuth_('drive', scope);
  fetchArgs.method = 'GET';

  var url = "https://www.googleapis.com/drive/v2/files/" + resource_id + "/revisions?key=" + myKey;
  var urlFetch = UrlFetchApp.fetch(url, fetchArgs);

... //snip

}

在 snip 中,urlFetch 已经成功,并且它有一个修订列表,其中每个修订都有 exportLinks。如果我使用其中一个导出链接并使用网络浏览器下载它,它总是 检索文档的最新版本,而不是指定的修订版本。这是一个错误还是我做错了什么?

换句话说,上述所有代码似乎都可以正常工作(API 调用成功并返回预期的内容),但返回的 exportLink URL 并未指向他们所说的修订版。

【问题讨论】:

    标签: google-apps-script google-drive-api


    【解决方案1】:

    同样的结果已被复制。

    我会为你报告这件事。给您带来不便,敬请见谅。

    【讨论】:

    • 一年多过去了,这个还是坏了。所有导出链接中似乎都忽略了修订 ID。有什么更新吗,@JunYoungGwak?
    • 很抱歉,我不再为 Google 工作了。我无法为这个问题提供支持。
    猜你喜欢
    • 1970-01-01
    • 2012-10-17
    • 2016-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多