Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
800 stars 340 forks source link

Callbackquery example #218

Closed laneboyandrew closed 4 years ago

laneboyandrew commented 4 years ago

Hello guys. I have inline keyboard where $fullink is a callback data. $keyboard[] = [ $telegram->buildInlineKeyboardButton($arr[2][$k], "", $fullLink) ]; Tell me please how using this lib get callback data and handle it. I just need to get values from callback data.

Eleirbag89 commented 4 years ago

https://core.telegram.org/bots/api#inlinekeyboardbutton

You need to set the attribuite "callback_data" and read it using $callback_query = $telegram->Callback_Query();

laneboyandrew commented 4 years ago

Thank you for reply. Today I've tried with Callback_Query method: $callbackQuery = $telegram->Callback_Query(); $message = $callbackQuery['message'];

and i tried with method Callback_Message(); $message = $telegram->Callback_Message();

Doesn't work, I really don't understand why.

Eleirbag89 commented 4 years ago

To read the callback data, you need $callbackQuery = $telegram->Callback_Query(); $data = $callbackQuery['data']

https://core.telegram.org/bots/api#callbackquery

laneboyandrew commented 4 years ago

Thank you so much, it's exactly what i wanted:)