使用 getWebhookInfo 检查 Telegram Webhook

getWebhookInfo 显示 Telegram 能否向你的机器人投递更新。下面介绍每个字段的含义以及常见投递错误的修复方法。

几次点击即可完成——无需写代码、无需服务器,直接在浏览器中操作。

检查我的 Webhook

WebhookInfo 字段

字段含义
url当前 Webhook URL。为空表示机器人使用 getUpdates(长轮询)。
pending_update_count等待投递的更新数。数量持续增长说明服务器没有接收。
last_error_date、last_error_message最近一次投递错误的时间(Unix)和内容。
last_synchronization_error_dateTelegram 数据中心之间同步更新时出错,通常是暂时的。
ip_addressTelegram 当前发送请求的 IP 地址。
max_connections最大同时连接数。
allowed_updates已订阅的更新类型;缺失表示使用默认集合。
has_custom_certificate是否上传了自签名证书。

使用 curl 检查

curl "https://api.telegram.org/bot$BOT_TOKEN/getWebhookInfo"

响应示例:

{
  "ok": true,
  "result": {
    "url": "https://example.com/telegram/webhook",
    "has_custom_certificate": false,
    "pending_update_count": 12,
    "ip_address": "203.0.113.10",
    "last_error_date": 1791446400,
    "last_error_message": "Wrong response from the webhook: 502 Bad Gateway",
    "max_connections": 40,
    "allowed_updates": ["message", "callback_query"]
  }
}

常见的 last_error_message

修复之后

刷新状态:last_error_date 会保留到下一次出错,因此请将其时间与当前时间比较。如果队列中有过期的更新,可用 drop_pending_updates 丢弃。

几次点击即可完成——无需写代码、无需服务器,直接在浏览器中操作。

检查我的 Webhook