相关疑难解决方法(0)

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

我正在使用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

}
Run Code Online (Sandbox Code Playgroud)

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

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

google-apps-script google-drive-api

6
推荐指数
1
解决办法
446
查看次数