setWebhook
Webhook ayarlar.
Dönüş değeri: Başarılı olduğunda True döndürür.
Parametreler
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
url | String | Evet | Webhook URL'si (boş dize = sil) |
certificate | InputFile | İsteğe bağlı | Açık anahtar sertifikası (kendinden imzalı için) |
ip_address | String | İsteğe bağlı | Webhook için IP adresi |
max_connections | Integer | İsteğe bağlı | Maks. bağlantı sayısı (1-100, varsayılan 40) |
allowed_updates | Array of String | İsteğe bağlı | Güncelleme türlerinin JSON dizisi |
drop_pending_updates | Boolean | İsteğe bağlı | Bekleyen güncellemeleri sil |
secret_token | String | İsteğe bağlı | X-Telegram-Bot-Api-Secret-Token için gizli token |
Örnek istek
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/setWebhook" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/telegram/webhook"}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/setWebhook",
json={
"url": "https://example.com/telegram/webhook"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/setWebhook`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"url": "https://example.com/telegram/webhook"
}),
});
console.log(await res.json());
Adım adım rehber: Telegram bot webhook kurulumu: URL, secret token, getWebhookInfo ve sorun giderme
İlgili metotlar
getWebhookInfoWebhook bilgilerini döndürür.deleteWebhookWebhook'u siler.getUpdatesGüncellemeleri alır. 'Başlat' düğmesini long polling için kullanın.