A
A
arybak20172019-04-08 22:28:55
PHP
arybak2017, 2019-04-08 22:28:55

Is it correct to receive updates from Webhook?

Hello, I use the following construction to get updates:
$data = json_decode(file_get_contents('php://input'));
the handler code itself looks like this:
<?php
include 'functions.php';
$Token = '';
$name = 'ExamplE2019_bot';
$data = json_decode(file_get_contents('php://input'));
$chat_id = '';
$text = $data['message']['text'];
$url = ' https://api.telegram.org/bot '.$Token.'/';
switch($text)
{
case '/start':
sendMessage($url,$chat_id,'ok');
break;
}
As a result, when sending the '/start' message, the bot does not respond. If you comment out the switch part and leave the message sent when the code is called in the browser window, then everything works. Please help me find the problem with this code!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
photozoom, 2019-04-09
@arybak2017

Try to see if updates come at all:
sendMessage($url,$chat_id, print_r($data, true));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question