getUpdates
获取更新。点击“开始”按钮可进行 Long Polling。
返回值: 调用成功时返回 Array of Update。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
offset | Integer | 可选 | 下一次请求的偏移量 |
limit | Integer | 可选 | 最大数量(1-100) |
timeout | Integer | 可选 | 超时时间(秒) |
allowed_updates | Array of String | 可选 | 类型的 JSON 数组 |
请求示例
curl
curl -s "https://api.telegram.org/bot$TOKEN/getUpdates"
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.get(f"https://api.telegram.org/bot{TOKEN}/getUpdates", timeout=30)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/getUpdates`);
console.log(await res.json());
分步教程: Telegram chat id 获取教程:查看用户、群组、频道和话题的聊天 ID
相关方法
getWebhookInfo返回 Webhook 信息。setWebhook设置 Webhook。deleteWebhook删除 Webhook。