skip to Main Content

I am working on a telegram bot using php, I want to resize my ReplyKeyboardMarkup button to fit each of the keyboards.

I want the first button to take the full width of the keyboard and the second and fourth button takes the middle then I want the last button to take the entire width at the bottom.

This is my code.

        $replyMarkup = array(
          'keyboard' => array(
              array("Get all foods", "Menu" "List", "Cancel")
          ),
          'resize_keyboard' => true
      );
      // checking if this user has already login in before
          $useit = json_encode($replyMarkup);
          $parameters = array(
              "chat_id" => $user_id,
              "parseMode" => "html",
              "text" => "Select country code",
              "reply_markup" => $useit
          );
        send("sendMessage", $parameters);

How can I resize each of my buttons using 'resize_keyboard' => true

2

Answers


  1. you can make your keyboard structure with arrays
    for example:

    $replyMarkup = array(
         'keyboard' => array(
              array("Get all foods"),
              array("Menu", "List"),
              array("Cancel")
         ),
         'resize_keyboard' => true
    );
    
    Login or Signup to reply.
  2. If you send it via "sendMessage?" then in json it should look like this:

    {"chat_id": "1234567890", "text": "messagetext123", "reply_markup": {"keyboard":[[{"text":"button1"},{"text":"button2"}]], "resize_keyboard":true}
    

    Boolean in resize_keyboard MUSTN’t be in braces.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search