0
我看到有幾篇關於「無法設置屬性」的帖子,而我仍在努力查明我在這裏失蹤的內容。我是JavaScript和GAS新手。我曾經寫過一本關於GAS的書,叫做「GScript企業應用程序基礎」。這段代碼來自於這本書,我沒有成功地工作。它表示要運行兩次,並且一次提示授權,只發生一次,並且在此之前和之後我都看到了這個錯誤。任何人都可以提出一個資源或我可以諮詢的東西來幫助弄清楚..或者也許更好地理解錯誤?謝謝!!TypeError:無法將屬性「googleOAuth」的undefined設置爲「」
CODE
/*
* Private for OAuth
* @ returns OAuth headers
*/
DOCS_LIST_API.googleOAuth = function() {
var oAuthConfig = UrlFetchApp.addOAuthService("google");
oAuthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken? scope=https://docs.google.com/feeds/");
oAuthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oAuthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig.setConsumerKey('anonymous');
oAuthConfig.setConsumerSecret('anonymous');
return {oAuthServiceName:'google', oAuthUseToken:"always"};
}
var DOCS_LIST_API = {};
/*
* @ args docID String the id for a Google Document
* @ args format String can be, "txt", "odt", "pdf", "html", "rtf", "doc", "png",
"zip"
* @ returns blob
*
*/
DOCS_LIST_API.GdocToFormat = function(docID, format){
var fetchArgs = DOCS_LIST_API.googleOAuth;
fetchArgs.headers = { "GData-Version": "3.0" };
fetchArgs.method = 'get';
var url = 'https://docs.google.com/feeds/download/documents/export/Export?id='+
docID+'&exportFormat='+format+'&format='+format;
return UrlFetchApp.fetch(url, fetchArgs);
}
// Run it twice
function doOAuth(){
try{
DOCS_LIST_API.GdocToFormat();
}catch(e){
}
}
OMG ..現在感覺像個白癡...... – jjones312