我正在使用Google驱动器脚本将Telegram机器人连接到驱动器工作表。
POST数据无法正常工作,但仍未定义。
function sendText() {
var url = tellurl + "/sendMessage?chat_id=" + id + "&text" + text;
var response =UrlFetchApp.fetch(url);
Logger.log(response.getContentText())
}
function doGet() {
return HtmlService.createHtmlOutput("hi there");
}
function doPost(e) {
var data =JSON.parse(e.postData.contents);
var text =data.message.text;
var id = data.data.message.chat.id;
var name = data.message.chat.first_name+""+data.message.chat.last_name;
var answer = "hi " + name + ", thanks " + text;
sendText(id,answer);
SpreadsheetApp.openById(ssid).getSheets()[0].appendRow([new Date(),id,name,text,answer]);
}