我是 GAS 新手,我正在尝试使用可视化查询从 Google 电子表格中提取数据。URI 在浏览器中完美运行,并且电子表格已发布。但是,来自 UrlFetchApp 的响应没有意义,因为数据已发布,不需要身份验证。这是我的代码:
function test () {
var url = 'https://docs.google.com/a/1ins.us/spreadsheet/tq?&key=<secretkey>&alt=json';
var q = '&tq=Select S,count(A) Where A is not Null Group By S pivot N';
var data = UrlFetchApp.fetch(url+q).getContentText();
data = data.slice(39,-2); //remove the callback function, is there a way to exec the function?
Logger.log(data);
}
这是 JSON 中返回的错误:
{"version":"0.6","status":"error","errors":[{"reason":"user_not_authenticated","message":"User not signed in","detailed_message":"\u003ca target=\u0022_blank\u0022 href=\u0022https://docs.google.com/spreadsheet/\u0022\u003eSign in\u003c/a\u003e"}]}
我错过了什么?我读到谷歌不希望在 GAS 中使用 Google.Visualizations。这是对这个问题的考虑吗?