function testGoogle() {
runQuery("0AjMMUAHNbxdgdFVSby1PcmtSU3A3bGdXQ2VPbkNYdUE", "SELECT A")
}
//http://www.google.com.ag/support/forum/p/apps-script/thread?tid=45dfe4b5213bb2a3&hl=en
function runQuery(spreadsheetID, selectQuery) {
var oauthConfig = UrlFetchApp.addOAuthService("google");
oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=https://spreadsheets.google.com/feeds/");
oauthConfig.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken");
oauthConfig.setConsumerKey("anonymous"); //ScriptProperties.getProperty("consumerKey"));
oauthConfig.setConsumerSecret("anonymous"); //ScriptProperties.getProperty("consumerSecret"));
var requestData3 = {
"method": "GET",
"headers": { "GData-Version": "3.0" },
"oAuthServiceName": "google",
"oAuthUseToken": "always",
};
var textURL1 = "http://spreadsheets.google.com/a/google.com/tq?key=" + spreadsheetID + "&tq=";
textURL1 = textURL1 + encodeURIComponent(selectQuery);
Logger.log(textURL1);
var result = UrlFetchApp.fetch(textURL1, requestData3);
Logger.log("result=" + result);
Logger.log("getContentText=" + result.getContentText());
Logger.log("getResponseCode()=" + result.getResponseCode());
}
Комментариев нет:
Отправить комментарий