Rx2*_*000 4 localhost urlfetch google-apps-script
这工作正常:
var resp = UrlFetchApp.fetch("someremotehost/SomeFile.csv");
resp.getResponseCode(); //returns 200
resp.getContentText(); //returns the data
Run Code Online (Sandbox Code Playgroud)
但是,在我的本地计算机上,我正在运行 xampp,SomeFile.csv 位于 htdocs/dev 中,但我无法让它在本地主机上工作:
var resp = UrlFetchApp.fetch("localhost/dev/SomeFile.csv");
resp.getResponseCode(); //returns 0.0
resp.getContentText() //returns nothing!
Run Code Online (Sandbox Code Playgroud)
我检查了 chrome-extension postman 并且http://localhost/dev/SomeFile.csv工作正常,那么为什么不起作用呢UrlFetchApp.fetch("http://localhost/dev/SomeFile.csv")?
这不起作用,因为应用程序脚本执行服务器端代码(在谷歌服务器中)。唯一的方法是创建一个 htmlService 应用程序并从前端使用 ajax。
| 归档时间: |
|
| 查看次数: |
6388 次 |
| 最近记录: |