Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

BUTTON_TYPE_INVALID when inline keyboard is used as reply_markup in InlineQueryResults #110

@MrDarkest

Description

@MrDarkest

Which version are you using?

3.5.0

Output:

Bad Request: BUTTON_TYPE_INVALID

Description of problem

When I set up a Markup object to use it in reply_markup property of Article class I get an error from Telegram:

Bad Request: BUTTON_TYPE_INVALID

Digging in the code I've find out that the problem is the button in the Markup.
I've set the Button like this:

$inlineKeyboard = new Markup();
$inlineKeyboardButton = new Button();
$inlineKeyboardButton->text = "Button text";
$inlineKeyboardButton->switch_inline_query = "inline_query";
$inlineKeyboard->inline_keyboard[][] = $inlineKeyboardButton;

and passed it to reply_markup property:

$inlineQueryResultArticle = new Article();
$inlineQueryResultArticle->title = "Answer Title";
$inlineQueryResultArticle->description = "Answer description";
[...]
$inlineQueryResultArticle->reply_markup = $inlineKeyboard;

But apparently Telegram dislike the "pay" and the "callback_game" properties of the Button in the json body if the button is used in AnswerInlineQuery even if they are null (in "callback_game" case) or false (in "pay" case).

I fixed temporary the problem by creating a new class (I called it "ButtonInlineAnswer") coping Button class, removing "pay" and "callback_game" properties and use this class instead of Button in the code before:

$inlineKeyboard = new Markup();
$inlineKeyboardButton = new ButtonInlineAnswer();
$inlineKeyboardButton->text = "Button text";
$inlineKeyboardButton->switch_inline_query = "inline_query";
$inlineKeyboard->inline_keyboard[][] = $inlineKeyboardButton;

If this can be accepted as solution I can open a pull request with this new class but if a better one can be found I'm glad to wait the official fix using mine meanwhile.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions