UrlFetchApp变量错误

问题描述 投票:0回答:1

我试图用UrlFetchApp Google Scripts API制作一个网页浏览器。然而,查询字符串为 ?url="https://google.com"它给我这个错误。

Exception: Invalid argument: "https://google.com" (line 3, file "Code")

但是当我用 param 在我下面的代码中,用于 https:/google.com确切的param值,不知为什么它工作得很好。

这是我的代码。

function doGet(e) {
 var param = e["parameter"]["url"];
 var response = UrlFetchApp.fetch(param);
 return HtmlService.createHtmlOutput(response);
}

谢谢你的帮助!

javascript html google-apps-script http-get urlfetchapp
1个回答
4
投票

这个修改怎么样?

我想在你的Web Apps脚本中,双引号是不需要的。

发件人

?url="https://google.com"

To:

?url=https://google.com

或者,当使用URL编码的时候,就变成了下面这样。

?url=https%3A%2F%2Fgoogle.com
© www.soinside.com 2019 - 2024. All rights reserved.