我很抱歉因为我不知道我在这里发布我的问题的任何脚本语言。我需要具有以下功能的脚本。我创建了https://sites.google.com/site/iitmamritwater网站。
我需要一个HTTP GET请求的Web服务,例如:https://sites.google.com/site/iitmamritwater?id=xxxxxxxxxx,它将验证在查询参数中提交的id。目前我只有2个有效的ID值,每个长度为10位数。 Web服务响应应该以其余额表示id有效性 - 如下所示:
If xxxxxxxxxx is one of the two possible correct values then response should be as below:
https://sites.google.com/site/iitmamritwater?id=xxxxxxxxxx
V;10.50;
If xxxxxxxxxy is not one of the two values then response should be as below:
https://sites.google.com/site/iitmamritwater?id=xxxxxxxxxy
N;00.00;
它是一个非常简单的脚本,但因为我不知道脚本我不能实现这个概念。我甚至不知道如何开始 - 有人可以发布相同的代码 - 这对我有用吗?它将节省我的项目开发时间。
答案 0 :(得分:1)
有关使用HtmlService提供多个html页面的示例,请参阅this answer。基本思路是编写doGet()
来接受一个查询参数,该参数将用于选择要提供的html页面。
在您的情况下,您应该根据对接收参数的评估,使用ContentService
输出相应的响应,而不是提供HTML页面。
function doGet(e) {
if (!e.parameter.id) {
// No id provided...
return ContentService.createTextOutput('Error - no id');
}
// else, get response for given id
var response = validateId( e.parameter.id );
// ...and serve it as text output
return ContentService.createTextOutput( response );
}
/**
* Get a response string for the given id
*
* @param {string} id 10 digit id
* @returns {string} Result of validation & lookup
*/
function validateId( id ) {
return "Under construction";
}