Telegram bot in PHP: why inline_keyboard sends nothing?

Write the bot in PHP without libraries. Reached inline-buttons in the message:
$arInfo["inline_keyboard"][0][0]["callback_data"]=1;
$arInfo["inline_keyboard"][0][0]["text"]="Button 1";
$arInfo["inline_keyboard"][1][0]["callback_data"]=2;
$arInfo["inline_keyboard"][1][0]["text"]="Button 2";
send($data['message']['chat']['id'],"Sample buttons",$arInfo);


The problem is that when you click on any of the buttons in the bot there is no request to the script. Trying to track this:
$data = file_get_contents('php://input');
$data = json_decode($data, true);
$data_kb = json_decode($data->callback_query->data, true);

When you click the button it appears a watch and nothing more happens.
In Botfather inline mode is enabled.
Please tell me how to animate buttons inline_keyboard. Thank you!
April 19th 20 at 12:34
1 answer
April 19th 20 at 12:36
Inline_keyboard and inline_mode different things.
Watch you appear and nothing happens because you did not handle the query callback and not return a response.
Try instead
$data_kb = json_decode($data->callback_query->data, true);

to do
$data_kb = $data['callback_query'];
Did. Nothing has changed. Still watch... - Trinity87 commented on April 19th 20 at 12:39
@Trinity87,
because you can not handle the query callback and not return a response


At $data_kb have.
You need to process callback_query and after processing to return the response. Read the documentation - johnny.Dicki commented on April 19th 20 at 12:42
@johnny.Dicki, put this:
send_answerCallbackQuery function($token, $callback_query_id, $text, $show_alert){
file_get_contents("https://api.telegram.org/bot".$token."/answerCallbackQuery?callback_query_id=".$callback_query_id."&text=".$text."&show_alert=".$show_alert);
}

if (isset($data['callback_query'])) {
 send_answerCallbackQuery(TOKEN, $data['callback_query']['id'], "check ", false);
}

- still have a watch and nothing more... - Trinity87 commented on April 19th 20 at 12:45
@Trinity87, means, somewhere something not so made. See logs - johnny.Dicki commented on April 19th 20 at 12:48
In General, I checked the logs - nothing in there.
Added a record to the file each response from the bot. And then it turned out that when you click on inline button there is NO response from the bot! No! The script writes to the file each incoming address, even if it is empty. When you click the button it is not at all. - Trinity87 commented on April 19th 20 at 12:51

Find more questions by tags TelegramBots