我正在使用电子邮件Audi API下载加密的form..When格式的用户邮箱,我将代码写入谷歌脚本并尝试运行,然后它给出错误504 :超时错误。当我使用OAuth游乐场这样做的时候,我成功地下载了mailbox..So,请给我一些建议来解决这个问题。
Code :
function downloadMailBox(user){
var user='user@mydomain.com'
var base='https://apps-apis.google.com/a/feeds/compliance/audit/'
var fetchArgs=googleOAuth_('google',base)
var userID=user.split('@')[0]
//Logger.log(userID)
var rawXml='<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">'+
'<apps:property name="packageContent" value="FULL_MESSAGE"/></atom:entry>'
fetchArgs.payload=rawXml
var uriForMailbox=base+'mail/export/mydomain.com/'+userID
UrlFetchApp.fetch(uriForMailbox,fetchArgs)
}
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("mydomain.com");
oAuthConfig.setConsumerSecret(consumersecret);
return {oAuthServiceName:name,
oAuthUseToken:"always",
contentType:'application/atom+xml',
method:'POST'
};
}
发布于 2012-11-01 11:48:15
我找到了一个解决方案……我只是把上面的代码写进了try-catch block..As超时错误来了,它转到了catch块,在那里我再次调用了上面的函数downloadmailBox()。(有时脚本执行正确,有时会出错).It会一次又一次地调用这个函数,直到获得成功。可能在2~3个attempts...So内就成功了,超时问题可以解决。
发布于 2012-10-31 11:54:11
过了多长时间,你就会得到这个错误?Google的脚本执行时间限制在5分钟左右。任何脚本,其花费的时间将超过此时间将超时。还有其他限制。你可以在Apps Script Dashboard上查看详细信息。
https://stackoverflow.com/questions/13156022
复制