Telegram Bot API
🌐 Türkçe

setWebhook

Kategori: Güncellemeler · Bot API 10.3 · Resmi dokümantasyon

Webhook ayarlar.

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

Parametreler

ParametreTürZorunluAçıklama
urlStringEvetWebhook URL'si (boş dize = sil)
certificateInputFileİsteğe bağlıAçık anahtar sertifikası (kendinden imzalı için)
ip_addressStringİsteğe bağlıWebhook için IP adresi
max_connectionsIntegerİsteğe bağlıMaks. bağlantı sayısı (1-100, varsayılan 40)
allowed_updatesArray of Stringİsteğe bağlıGüncelleme türlerinin JSON dizisi
drop_pending_updatesBooleanİsteğe bağlıBekleyen güncellemeleri sil
secret_tokenStringİsteğe bağlıX-Telegram-Bot-Api-Secret-Token için gizli token

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/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