google-apps-script - 从外部域获取 Google 表格中的活动用户名
问题描述
我有一个已发布的网络应用程序:
function doGet(request) {
// DocumentApp.getActiveDocument();
SpreadsheetApp.getActive();
var about = Drive.About.get();
var user = about.name;
// Logger.log(Session.getActiveUser().getEmail());
return ContentService.createTextOutput(user);
}
...在这个网址:
https://script.google.com/macros/s/AKfycbzTlhKJXrTAEPEba0l1KWqqzlkul2ntC-0iHi7_POj0wk7j3R6K/exec
这会产生用户全名所需的结果(在批准对用户数据的授权后 - URL 的后续运行不会提示进行身份验证或批准)
那就是我想从此 App Script 中检索的数据:
function Test3() {
var options = {
'method' : 'get',
'followRedirects' : true,
// 'validateHttpsCertificates' : 'true',
'muteHttpExceptions' : true,
'contentType' : 'null'
};
var url = "https://script.google.com/macros/s/AKfycbzTlhKJXrTAEPEba0l1KWqqzlkul2ntC-0iHi7_POj0wk7j3R6K/exec"
var response = UrlFetchApp.fetch(url, options);
// var response = test2() ;
// var myName = response.getContentText();
Browser.msgBox("[" + response + "]");
}
但我无法获得这些数据。相反,我得到一个页面 HTML 文本,它相当于一个 Google 登录页面。
同样,只需从浏览器手动运行 URL,因为任何用户都会生成用户名网页,那么为什么从应用脚本运行时,它不能只检索该页面的结果?
我错过了什么?当然,我离获取这些数据还有一些简单的语法。
解决方案
推荐阅读
- python - Python中如何统计考试成绩的输入量?
- c++ - 致命错误:opencv2/opencv.hpp:没有这样的文件或目录
- mysql - SQOOP 导出到 MySQL
- algorithm - 在图表中查找组
- php - “拒绝访问”MVC XAMMP 设置
- python - Apache Server 2.2.34 x64 - 使用 mod_wsgi - 运行 Python 脚本 - 无法使用 WSGIDaemonProcess 守护程序模式
- r - 如何将 RCurl 和 curl 更新到主机上的版本?
- c++ - 开发需要大量 C++ 库的 R 包的最佳方法是什么?
- c# - File.ReadAllText 不返回 C# 中的完整内容
- java - skip() 方法是短路操作吗?