Telegram Bot API

sendSharedWidget

Danh mục: Widget · Bot API 10.5 · Tài liệu chính thức

Lịch sử phiên bản: Được thêm trong Bot API 10.4

Gửi lại widget dùng chung do bot tạo (Bot API 10.4).

Giá trị trả về: Nếu thành công, trả về Message.

Tham số

Tham sốKiểuBắt buộcMô tả
chat_idInteger or StringCóID chat hoặc @username
message_thread_idIntegerTùy chọnID chủ đề diễn đàn
widget_idStringCóID widget dùng chung (widget.id từ tin nhắn đã gửi)
chat_dataStringTùy chọnTrạng thái của widget trong chat này (chat_data), 0-1024 byte
captionStringTùy chọnChú thích (0-1024)
parse_modeStringTùy chọnHTML, Markdown, MarkdownV2
caption_entitiesArray of MessageEntityTùy chọnMảng JSON MessageEntity cho chú thích
show_caption_above_mediaBooleanTùy chọnHiển thị chú thích phía trên widget
disable_notificationBooleanTùy chọnGửi không âm thanh
protect_contentBooleanTùy chọnBảo vệ nội dung
allow_paid_broadcastBooleanTùy chọnCho phép gửi hàng loạt trả phí
message_effect_idStringTùy chọnID hiệu ứng tin nhắn
reply_parametersReplyParametersTùy chọnĐối tượng JSON ReplyParameters
reply_markupInlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReplyTùy chọnJSON: InlineKeyboardMarkup / ReplyKeyboardMarkup / ReplyKeyboardRemove / ForceReply

Mô tả tham số chỉ là bản tóm tắt ngắn gọn; xem tài liệu chính thức để đọc toàn văn.

Ví dụ request

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendSharedWidget" \
  -H "Content-Type: application/json" \
  -d '{"chat_id":123456789,"widget_id":"WIDGET_ID"}'

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/sendSharedWidget",
    json={
        "chat_id": 123456789,
        "widget_id": "WIDGET_ID"
    },
    timeout=30,
)
print(resp.json())

JavaScript

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendSharedWidget`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "chat_id": 123456789,
    "widget_id": "WIDGET_ID"
  }),
});
console.log(await res.json());

Hướng dẫn từng bước: Ví dụ widget Telegram: HTML hoàn chỉnh và code bot Python