editMessageMedia
Chỉnh sửa media trong tin nhắn.
Giá trị trả về: Nếu thành công, trả về Message or True.
Tham số
| Tham số | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
business_connection_id | String | Tùy chọn | ID kết nối doanh nghiệp |
chat_id | Integer or String | Tùy chọn | ID chat |
message_id | Integer | Tùy chọn | ID tin nhắn |
inline_message_id | String | Tùy chọn | ID tin nhắn inline |
media | InputMedia | Có | Đối tượng JSON InputMedia |
reply_markup | InlineKeyboardMarkup | Tùy chọn | JSON: InlineKeyboardMarkup |
Ví dụ request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/editMessageMedia" \
-H "Content-Type: application/json" \
-d '{
"media": {
"type": "photo",
"media": "https://telegram.org/img/t_logo.png"
}
}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/editMessageMedia",
json={
"media": {
"type": "photo",
"media": "https://telegram.org/img/t_logo.png"
}
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/editMessageMedia`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"media": {
"type": "photo",
"media": "https://telegram.org/img/t_logo.png"
}
}),
});
console.log(await res.json());
Hướng dẫn từng bước: Cách tạo bot Telegram từ A đến Z: BotFather, token và tin nhắn đầu tiên
Phương thức liên quan
editMessageTextChỉnh sửa nội dung tin nhắn.editMessageCaptionChỉnh sửa chú thích của media.editMessageReplyMarkupChỉnh sửa reply markup của tin nhắn.editMessageLiveLocationChỉnh sửa vị trí trực tiếp.stopMessageLiveLocationDừng chia sẻ vị trí trực tiếp.editMessageChecklistChỉnh sửa checklist.