I am trying to develop city bot for telegram, but meet a problem.
After sending message to bot, Telegram sends 2 duplicate requests to a webhook url.
Webhook script works twice and sends twice responses to user.
Script – hellobot.php from official telegram docs.
Server vps hosting with self-signed SSL, with uploaded cert key to telegram.
From server logs.
149.154.167.209 – – [28/Jun/2016:13:48:00 +0300] “POST /apps/gate.php HTTP/1.0” 200 86 “-” “-
149.154.167.209 – – [28/Jun/2016:13:48:00 +0300] “POST /apps/gate.php HTTP/1.1” 200 86 “-” “-
149.154.167.209 – – [28/Jun/2016:13:48:00 +0300] “POST /apps/gate.php HTTP/1.0” 200 86 “-” “-
149.154.167.209 – – [28/Jun/2016:13:48:00 +0300] “POST /apps/gate.php HTTP/1.1” 200 86 “-” “-
How to fix this?
3
Answers
Could you post some code;
If you are asking to
getupdates
and send response to user upon eachresult
; it may send the duplication because you did not set the offset right#getupdates_offset
when Telegram receive a message from your bot user, send the message to your webhook URL in JSON format.
if
then Telegram send the message to your server again.
Your bot should store last
update_id
, Then compare by update_id