2012-06-21 3 views
0

"속성을 설정할 수 없습니다"와 관련된 게시물이 있으며 여기에서 누락 된 것을 찾아내는 데 어려움을 겪고 있습니다. 나는 Javascript와 GAS가 처음이다. 나는 GAS라는 책 "GScript enterprise application essentials"를 썼다. 이 코드는 책에서 나왔고 성공하지 못했습니다. 그것은 두 번 실행하고 한 시점에서 그것은 한 번만 일어난 인증을 묻는 메시지를 표시하고 그 전에 그 오류를 본 적이있다. 누구든지 리소스 또는 내가 그것을 알아낼 수 있도록 상담 할 수있는 뭔가를 제안 할 수 있습니다 .. 또는 어쩌면 더 나은 오류를 이해 ?? 감사!! 당신이 변수로 선언하기 전에 DOCS_LIST_API의 속성을 설정하려고하기 때문에TypeError : 정의되지 않은 "googleOAuth"속성을 ""로 설정할 수 없습니다.

/* 
* 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){ 
    } 
} 

답변

2

코드는 오류가 발생합니다.

var DOCS_LIST_API = {};을 맨 위로 이동하십시오.

+0

OMG .. 지금 바보처럼 느껴지세요. – jjones312

관련 문제