I use the library telegram bot sdk, I got to the point where I need to make inline buttons. When you click on them, the contents of the callback_data parameter should be given, which we later process and display, for example, another keyboard. In the issue to the repository on github I saw how, having upgraded to 3 dev master, data can be obtained something like this:

$this->bot->getWebhookUpdate()->getCallbackQuery()->getData(); 

However, my data does not come. Did this way:

 $this->bot->getWebhookUpdate()["callback_query"]["data"] 

Nothing too.

This is how the bot handler file looks like:

 <?php require 'vendor/autoload.php'; use Kafkiansky\Engine\Progbot\Helper; use Kafkiansky\Engine\Database\EasyOrm; use Telegram\Bot\Keyboard\Keyboard; $settings = require 'settings.php'; $token = require 'token.php'; $bot = new Helper($token["token"]); $db = new EasyOrm($settings); $message = $db->findOneEntity()->content; $keyboard_default = Keyboard::make() ->inline() ->row( Keyboard::inlineButton(['text' => 'Создать пост', 'callback_data' => '/get']) ) ->row( Keyboard::inlineButton(['text' => 'Отложенные', 'callback_data' => 'Данные сохранены']), Keyboard::inlineButton(['text' => 'Редактировать', 'callback_data' => 'Данные не сохранены']) ) ->row( Keyboard::inlineButton(['text' => 'Опубликовать', 'callback_data' => 'Данные сохранены']), Keyboard::inlineButton(['text' => 'Назад', 'callback_data' => 'Данные не сохранены']) ); $keyboard_get_new = Keyboard::make() ->inline() ->row( Keyboard::inlineButton(['text' => 'Библиотеку программиста', 'callback_data' => '']) ) ->row( Keyboard::inlineButton(['text' => 'Назад', 'callback_data' => '']) ); switch ($bot->getText()) { case "/start": $bot->sendMessage([ 'chat_id' => $bot->getChatId(), 'text' => $bot->getUsername() ]); $db->store($bot->getFirstName(), $bot->getUsername(), $bot->getChatId()); break; case "/help": $bot->sendMessage([ 'chat_id' => $bot->getChatId(), 'text' => $message, 'reply_markup' => $keyboard_default, 'one_time_keyboard' => true ]); break; default: $bot->sendMessage([ 'chat_id' => $bot->getChatId(), 'text' => 'Я не понимаю, о чём вы' ]); break; } switch ($bot->getCallbackData()) { case "/get": $bot->sendMessage([ 'chat_id' => $bot->getChatId(), 'text' => 'Текст', 'reply_markup' => $keyboard_get_new, 'one_time_keyboard' => true ]); break; } 

Who faced similar, as decided?

  • Did you manage to solve the problem? I have the same question - aspirinemaga Nov.

0