Telegram Bot API

sendWidget

Kategori: Widget'lar · Bot API 10.5 · Resmi dokümantasyon

Sürüm geçmişi: Bot API 10.4 sürümünde eklendi

HTML widget içeren bir mesaj gönderir (Bot API 10.4).

Dönüş değeri: Başarılı olduğunda Message döndürür.

Parametreler

ParametreTürZorunluAçıklama
chat_idInteger or StringEvetSohbet ID'si veya @username
message_thread_idIntegerİsteğe bağlıForum konusu ID'si
htmlStringEvetWidget'ın HTML kodu: 1-32768 bayt, zlib sıkıştırmasından sonra en fazla 4096 bayt
widthIntegerİsteğe bağlıMantıksal piksel cinsinden widget genişliği (mesajın tam genişliği için boş bırakın)
heightIntegerİsteğe bağlıMantıksal piksel cinsinden widget yüksekliği, 50-600 (içeriğe sığdırmak için boş bırakın)
public_dataStringİsteğe bağlıWidget'ın genel durumu (public_data), 0-1024 bayt — widget'ın gösterildiği her yerde görünür
chat_dataStringİsteğe bağlıWidget'ın bu sohbetteki durumu (chat_data), 0-1024 bayt
captionStringİsteğe bağlıAltyazı (0-1024)
parse_modeStringİsteğe bağlıHTML, Markdown, MarkdownV2
caption_entitiesArray of MessageEntityİsteğe bağlıAltyazı için JSON MessageEntity dizisi
show_caption_above_mediaBooleanİsteğe bağlıAltyazıyı widget'ın üstünde göster
allow_queriesBooleanİsteğe bağlıWidget'ın bota sorgu göndermesine izin ver (widget_query)
is_sharedBooleanİsteğe bağlıPaylaşılan widget oluştur — sendSharedWidget ile yeniden gönderilebilir
disable_notificationBooleanİsteğe bağlıSessiz gönder
protect_contentBooleanİsteğe bağlıİçeriği koru
allow_paid_broadcastBooleanİsteğe bağlıÜcretli yayına izin ver
message_effect_idStringİsteğe bağlıMesaj efekti ID'si
reply_parametersReplyParametersİsteğe bağlıJSON ReplyParameters nesnesi
reply_markupInlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReplyİsteğe bağlıJSON: InlineKeyboardMarkup / ReplyKeyboardMarkup / ReplyKeyboardRemove / ForceReply

Parametre açıklamaları kısa özetlerdir; tam metin için resmi dokümantasyona bakın.

Örnek istek

curl

curl -s -X POST "https://api.telegram.org/bot$TOKEN/sendWidget" \
  -H "Content-Type: application/json" \
  -d '{
  "chat_id": 123456789,
  "html": "<h3>Order #1042</h3><p>2 × Margherita</p><button>Track the order</button>"
}'

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/sendWidget",
    json={
        "chat_id": 123456789,
        "html": "<h3>Order #1042</h3><p>2 × Margherita</p><button>Track the order</button>"
    },
    timeout=30,
)
print(resp.json())

JavaScript

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/sendWidget`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "chat_id": 123456789,
    "html": "<h3>Order #1042</h3><p>2 × Margherita</p><button>Track the order</button>"
  }),
});
console.log(await res.json());

Adım adım rehber: Telegram widget: bot mesajının içinde çalışan etkileşimli HTML