editMessageLiveLocation
编辑实时位置。
返回值: 调用成功时返回 Message or True。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
business_connection_id | String | 可选 | 商业连接 ID |
chat_id | Integer or String | 可选 | 聊天 ID |
message_id | Integer | 可选 | 消息 ID |
inline_message_id | String | 可选 | 内联消息 ID |
latitude | Float | 是 | 纬度 |
longitude | Float | 是 | 经度 |
live_period | Integer | 可选 | 实时位置有效期(秒) |
horizontal_accuracy | Float | 可选 | 精度(米,0-1500) |
heading | Integer | 可选 | 方向(度,1-360) |
proximity_alert_radius | Integer | 可选 | 接近提醒半径(1-100000) |
reply_markup | InlineKeyboardMarkup | 可选 | JSON 对象:InlineKeyboardMarkup |
请求示例
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/editMessageLiveLocation" \
-H "Content-Type: application/json" \
-d '{"latitude":51.5007,"longitude":-0.1246}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/editMessageLiveLocation",
json={
"latitude": 51.5007,
"longitude": -0.1246
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/editMessageLiveLocation`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"latitude": 51.5007,
"longitude": -0.1246
}),
});
console.log(await res.json());
分步教程: Telegram 机器人教程:从零创建 Telegram 机器人并发送第一条消息
相关方法
editMessageText编辑消息文本。editMessageCaption编辑媒体说明文字。editMessageMedia编辑消息中的媒体。editMessageReplyMarkup编辑消息的回复标记。stopMessageLiveLocation停止更新实时位置。editMessageChecklist编辑清单。