Answer the question
In order to leave comments, you need to log in
How to send commands to the Telegram bot when choosing in the menu?
There is a code that creates and sends text when a key is pressed.
$keyboard = array(array("test1","test2","test3"));
$resp = array("keyboard" => $keyboard,"resize_keyboard" => true,"one_time_keyboard" => true);
$reply = json_encode($resp);
$url = $GLOBALS[website]."/sendmessage?chat_id=".$chatId."&text=/hi&reply_markup=".$reply;
file_get_contents($url);
Answer the question
In order to leave comments, you need to log in
I don’t understand how to catch which of the 3 keys I pressed?
and how to make the menu have one text, and when you click on it, for example, a command is sent?
Actually, as it was found out [elsewhere], when the user clicks on different buttons, (in this case) "test1", "test2" and "test3" will come - that is, the text set by the bot for the button that the user clicked
Respectively , the second part of the question can be done by comparing the received text with the text of the buttons and then calling the desired command handler for the received command.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question