Yangilanishlar
setWebhook
Yangilanishlarni HTTPS manzilingizga yuborishni yoqadi.
POST
https://api.zamin.app/bot<TOKEN>/setWebhookGET ham ishlaydi. Parametrlar: query, JSON, form yoki multipart β batafsil.
Yangi yangilanishlar ko'rsatilgan HTTPS manzilga JSON sifatida POST qilinadi. Webhook yoqilgach, getUpdates ishlamaydi va ochiq long poll 409 bilan tugaydi.
- Faqat https, portlar: 443, 80, 88, 8443. Sertifikat haqiqiy bo'lishi kerak (o'z-o'zidan imzolangan sertifikat qo'llab-quvvatlanmaydi).
- Manzil server tomonidan resolve qilinadi va xususiy, lokal yoki Zamin'ning o'z manzillariga ishora qilsa rad etiladi (SSRF qoidalari).
secret_tokenberilsa, har bir so'rovdaX-Zamin-Bot-Api-Secret-Tokensarlavhasida keladi. Uni albatta tekshiring.url: ""bilan chaqirish β deleteWebhook bilan bir xil.
Parametrlar
| Parametr | Turi | Majburiy | Cheklov | Izoh |
|---|---|---|---|---|
url | String | Majburiy | β€2048 belgi | HTTPS manzil. Bo'sh qator β webhookni o'chiradi. |
secret_token | String | Ixtiyoriy | 1β256 belgi, A-Z a-z 0-9 _ - | Har bir yetkazishda sarlavhada keladi. |
max_connections | Integer | Ixtiyoriy | 1β100 | Standart: 40. Saqlanadi va getWebhookInfo'da ko'rinadi, lekin hozircha yetkazish ketma-ket (bitta ulanish). |
allowed_updates | Array of String | Ixtiyoriy | β€20 element | Qaysi turlar kerak (ro'yxat getUpdates'dagidek). Berilmasa β barcha turlar (avvalgi filtr bekor bo'ladi), chat_member'dan tashqari: uni olish uchun ro'yxatda aniq ko'rsating. |
drop_pending_updates | Boolean | Ixtiyoriy | β | true β navbatdagi barcha yangilanishlarni o'chiradi. |
Javob
Natija (result): true
JSON
{"ok": true, "result": true}Xatolar
| Kod | Tavsif | Sabab va yechim |
|---|---|---|
| 400 | Bad Request: bad webhook: HTTPS url must be provided for webhook | Manzil https:// bilan boshlansin. |
| 400 | Bad Request: bad webhook: Webhook can be set up only on ports 80, 88, 443 or 8443 | Ruxsat etilgan portdan foydalaning. |
| 400 | Bad Request: bad webhook: IP address is not allowed | Host xususiy/lokal manzilga resolve bo'ladi (DNS javoblaridan birortasi bo'lsa ham). |
| 400 | Bad Request: bad webhook: host is not allowed | localhost, *.local, *.internal, zamin.app va uning subdomenlari taqiqlangan. |
| 400 | Bad Request: bad webhook: Failed to resolve host | DNS yozuvi topilmadi. |
| 400 | Bad Request: bad webhook: invalid URL / invalid host | URL yoki host noto'g'ri yozilgan. |
| 400 | Bad Request: bad webhook: credentials in URL are not allowed | URL'da login:parol bo'lmasin; maxfiylik uchun secret_token ishlating. |
| 400 | Bad Request: certificate and ip_address are not supported | Bu parametrlarni yubormang. |
| 400 | Bad Request: secret_token: secret token contains unallowed characters | Faqat A-Z, a-z, 0-9, _ va -; 1β256 belgi. |
Istalgan metodda bo'lishi mumkin: 401 Unauthorized, 403 Forbidden: bot is suspended, 429 Too Many Requests, 400 Bad Request: <maydon>: β¦ β xato kodlari.
Misol
Python
import os
import requests
TOKEN = os.environ["ZAMIN_BOT_TOKEN"]
API = f"https://api.zamin.app/bot{TOKEN}"
r = requests.post(
f"{API}/setWebhook",
json={
"url": "https://bot.example.com/zamin/webhook",
"secret_token": os.environ["ZAMIN_WEBHOOK_SECRET"],
"allowed_updates": ["message", "callback_query"],
"drop_pending_updates": True,
},
timeout=15,
)
print(r.json())curl
curl -s -X POST "https://api.zamin.app/bot$ZAMIN_BOT_TOKEN/setWebhook" \
-H "Content-Type: application/json" \
-d '{
"url": "https://bot.example.com/zamin/webhook",
"secret_token": "my-long-random-secret",
"allowed_updates": ["message", "callback_query"]
}'