G
G
Gluck Virtualen2016-10-23 07:22:01
API
Gluck Virtualen, 2016-10-23 07:22:01

Why does the keyboard in Telegram bot work selectively?

Hello
I am writing a bot, there is a task to show the user a keyboard with a callback.
The keyboard code looks like this:

apiRequestJson("sendMessage", array('chat_id' => $chat_id, "text" => $out, 'parse_mode' => 'HTML',
        'reply_markup' => array(
            'keyboard' => array(
                array(
                    array('text' => '11', 'url' => 'https://google.com'), 
                    array('text' => '33', 'request_contact' => true),       // работает 
                    array('text' => '22', 'callback_data' => 'callback')
            )),
            'one_time_keyboard' => true,
            'resize_keyboard' => true
        )
    ));

The button "33" works as described in the dock, the rest stupidly pass their text and nothing else. Url is not opened, callback is not called.
Did I miss something?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nllm, 2016-10-23
@gluck59

You mixed a normal keyboard and an inline keyboard in one.
url and callback for buttons can be specified only for inline keyboard
https://core.telegram.org/bots/api#keyboardbutton

...
'keyboard' => array(
                array(
                    array('text' => '33', 'request_contact' => true),       // работает 
            )),
...

https://core.telegram.org/bots/api#inlinekeyboardbutton
...
'inline_keyboard' => array(
                array(
                    array('text' => '11', 'url' => 'https://google.com'), 
                    array('text' => '22', 'callback_data' => 'callback')
            )),
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question