问题描述
我在谷歌脚本中用这个函数设置了 webHook
function setWebhook() {
var url = telegramUrl + "/setWebhook?url=" + webAppUrl;
var response = UrlFetchApp.fetch(url);
}
其中电报 url 包含电报令牌,而 web AppUrl 是 google script exec url。 当我尝试使用功能获取 webhook 信息时
function getWebhookinfo() {
var url = telegramUrl + "/getWebhookInfo";
var response = UrlFetchApp.fetch(url);
Logger.log(response.getContentText());
}
我收到此错误消息:
[20-12-22 10:41:23:115 CET] {"ok":true,"result":{"url":"https://script.google.com/macros/s/___________________________/exec","has_custom_certificate":false,"pending_update_count":0,"last_error_date":1608570964,"last_error_message":"Wrong response from the webhook: 401 Unauthorized","max_connections":40,"ip_address":"172.217.17.78"}}
解决方法
我遇到了同样的问题,请检查您的部署配置:以您的名字运行并允许所有人访问:
还要检查这个https://gist.github.com/manzoorwanijk/ee9ed032caedf2bb0c83dea73bc9a28e