如何获取Google Drive API中的修订版的exportLinks

时间:2013-06-24 20:14:50

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

我正在使用Google Apps脚本尝试获取各种Google图表修订版的exportLinks列表。下面的代码重现了这个问题。要试用它,请使用图形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

}

在剪辑中,urlFetch已经成功,它有一个修订列表,每个版本都有exportLinks。如果我抓住其中一个exportLink并使用Web浏览器下载它,<​​em>总是检索文档的最新版本,而不是指定的版本。这是一个错误还是我做错了什么?

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

1 个答案:

答案 0 :(得分:0)

同样的结果已被复制。

我会为你报告。很抱歉给您带来不便。