I am new to telegram BOT Api, i just set webhook , when i manually surf my web link, My Bot is receiving messages, but when i send commands or any text from telegram bot i am not getting any reply from the server
I didnt get any problem while setting the webhook, my certificate is self signed , i also uploaded the self signed certificate while setting the webhook, because telegram says to upload self signed (.PEM) certificate , but still i am not receiving any message while i send commands or any text from Telegram BOT but Manual surf is working
Here is my sample code
<?php
ini_set('error_reporting', E_ALL);
$botToken = "MY_TOKEN";
$website ="https://api.telegram.org/bot".$botToken;
$update=file_get_contents("php://input");
$update = json_decode($content, TRUE);
$chatID = $update["message"]["chat"]["id"];
$message =$update["message"]["text"];
switch ($message) {
case "/test":
sendMessage($chatID, "test");
break;
case "/cancel":
sendMessage($chatID, "cancel");
break;
default:
sendMessage($chatID, "default");
break;
}
function sendMessage($chat_id, $msg){
$url = $GLOBALS["website"]."/sendMessage?chat_id=".$chat_id."&text=".urlencode($msg);
file_get_contents($url);
}
please help me that where i am making my mistake??
3
Answers
In sendMessage() function you’ve written into the url sendMessage, try instead sendmessage (lowcase)
just here must change ::
before :
after :
This code is work