I want to make a bot of telegram using php , but when sending a message to the bot no I receive an answer from webhook .
I have a site in infinityfree , the domain edutrack.ml
got it in freenom and generates a certificate ssl with cloudfare
. My site already tells me that it is safe.
I already redirected my bot to webhook from
https://api.telegram.org/bot714292300:AAG3m_Vk96C4KEJmAy50O2ZWurOa******/setWebhook?url=https://edutrack.ml/webhook.php
The code for the webhook that I am using is:
<?php
define ('url',"https://api.telegram.org/bot714292300:AAG3m_Vk96C4KEJmAy50O2ZWurOa******/");
$update = json_decode(file_get_contents('php://input') ,true);
$chat_id = $update['message']['chat']['id'];
# $chat_id = "43914****";
$name = $update['message']['from']['first_name'];
$message = 'Hi '.$name;
file_get_contents(url."sendMessage?text=".$message."&chat_id=".$chat_id);
If I run it locally with XAMPP and assign the ID
manually (the commented line) when I refresh the page the bot if it sends the greeting to the user (only the Hi
).
I want to know if someone can guide me to make the bot work with the webhook , or if I need to do something, or configure something. Thank you in advance.