-2

i want to create a Telegram bot, i write this codes, and also i set the Webhook, this code return the Json response from telegram bot to itself, but i don`t know why it is not working.. any help and guide will be appreciated.

$token = 'my token';
// read incoming info and grab the chatID 
$json = file_get_contents('php://input');
$telegram = urldecode ($json);
$results = json_decode($telegram); 




// send reply
$url = 'https://api.telegram.org/bot'.$token.'/sendMessage?chat_id=80853440&text='.$json;
 file_get_contents($url);
amin
  • 1
  • 4

1 Answers1

0

GET Requests are limited. Try using curl for a POST request or write an array containing chat_id, ...
Then use

$arrayname["method"] = "sendMessage"; //Req method for example sendMessage
echo json_encode($arrayname);

Please read Telegram Api and php.net for more informations.

Pato05
  • 326
  • 1
  • 14