P
P
PaulMil2020-04-17 18:14:08
Bots
PaulMil, 2020-04-17 18:14:08

Telegram bot in PHP: why doesn't inline_keyboard send anything?

I am writing a bot in PHP without libraries. Reached the inline buttons in the message:

$arInfo["inline_keyboard"][0][0]["callback_data"]=1;
$arInfo["inline_keyboard"][0][0]["text"]="Кнопка 1";
$arInfo["inline_keyboard"][1][0]["callback_data"]=2;
$arInfo["inline_keyboard"][1][0]["text"]="Кнопка 2";
send($data['message']['chat']['id'],"Примеры кнопок",$arInfo);


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

When you click on the button, a clock appears on it and nothing else happens.
Botfather inline mode is enabled.
Please tell me how to animate the inline_keyboard buttons. Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zudwa, 2020-04-17
@pembrock

Inline_keyboard and inline_mode are different things.
You get a clock and nothing happens because you do not process the callback query in any way and do not return a response.
Try instead

$data_kb = json_decode($data->callback_query->data, true);

do
$data_kb = $data['callback_query'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question