小编Tor*_*Guy的帖子

ASP.NET MVC路由通过方法属性

StackOverflow播客#54中,Jeff提到他们通过处理路由的方法上方的属性在StackOverflow代码库中注册其URL路由.听起来像一个很好的概念(菲尔哈克提出的关于路线优先事项的警告).

有人可以提供一些样本来实现这一目标吗?

此外,使用这种路由风格的任何"最佳实践"?

asp.net-mvc routing url-routing decorator

80
推荐指数
3
解决办法
2万
查看次数

如何获取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
查看次数