因此,我需要一些东西来充当通知程序并将其连接到我的脚本,因此我决定尝试Telegram。我已经成功设置了Telegram机器人。但是我在通过漫游器发送HTML格式的消息时遇到了麻烦。
function wire(message) {
var token ='xxxxxxx';
var channel_id = 'xxxx'
var uid = 'https://api.telegram.org/bot'+token+'/sendMessage?chat_id='+channel_id+'&text='+message+'&parse_mode=HTML';
Logger.log(UrlFetchApp.fetch(uid));
}
function test() {
var body = "You were sent a message from <a href = http://www.example.com/profiles.php?XID=xxxxx>Batman</a> with the message:Hi";
var bish = encodeURIComponent(body);
wire(bish);
}
运行功能 test 给我一个错误,如下:
{"ok":false,"error_code":400,"description":"Bad Request: can't parse entities: Unexpected end of name token at byte offset 40"}
我在这里做错了什么?任何输入将不胜感激。
答案 0 :(得分:1)
href属性必须用引号引起来。参见docs。
尝试:
var body = 'You were sent a message from <a href = "http://www.example.com/profiles.php?XID=xxxxx">Batman</a> with the message:Hi';