4

$media[]=['⬅️',''];

It's my telegram bot buttons.

it's very large i don't like this.

How Can I Miniaturize telegram button?

I think i need this : resize_keyboard

But i don't know how use this for Miniaturize buttons.

its my function request:

var_dump(
    makeHTTPRequest('sendMessage',[
        'chat_id'=>userid,
        'text'=>"Text",
        'reply_markup'=>json_encode(array('keyboard'=> [['⬅️','Button','']]))
    ])
);

How Can I Miniaturize this buttons?

3 Answers3

5
var_dump(
    makeHTTPRequest('sendMessage',[
        'chat_id'=>userid,
        'text'=>"Text",
        'reply_markup'=>json_encode(array('keyboard'=> [['⬅️','Button','']],'resize_keyboard' => true))
    ])
);
amir ntm
  • 84
  • 8
1

what are you mean? you want to change button size or you talk about Emoji?

if about resize, your function should look like this:

$reply_markup = array(
    'keyboard' => array(['⬅️','Button','']),
    'resize_keyboard' => true,
    'selective' => true
);

var_dump(
    makeHTTPRequest('sendMessage',[
        'chat_id'=>userid,
        'text'=>"Text",
        'reply_markup'=>$reply_markup
    ])
);

you can use emoji as unicode, shortcode or copying raw image.

if you are using PHP, the simple way is to insert Unicode or UTF-8 characters in button text. this link more usefull for PHP Emoji Table

also, you can find many different examples on github and others

for example, one of my first bot for pizza place :)

<?php

define('TOKEN', '<token>');
define('URL', 'https://api.telegram.org/bot'.TOKEN.'/');

$bot = json_decode(file_get_contents('php://input'), true);
$chat = $bot["message"]["chat"]["id"];
$user = $bot["message"]["chat"]["first_name"].' '.$bot["message"]["chat"]["last_name"];
$text = $bot["message"]["text"];

$menuMsg = "Hello, ${user}! Enjoy a new Banana Pie. \xF0\x9F\x8D\x8C \xF0\x9F\x98\x8A";

if ( $text == "/start" ){

  $Menu = array(
    array("\xF0\x9F\x8D\xB4 Menu", "\xF0\x9F\x92\xB0 Checkout"),
    array("\xE2\x86\xAA Last oreder", "\xE2\x9D\x8C Cancel")
  );

  send_keyb(
    $chat,
    $menuMsg,
    $Menu
  );
}

function send_keyb( $chat, $msg, $keyb ){

  $content = array(
    'parse_mode' => 'HTML',
    'chat_id' => $chat,
    'text' => $msg,
    'reply_markup' => keyboard($keyb)
  );

  curlGET(
    URL."sendMessage?".http_build_query( $content )
  );
}

function keyboard( $keyb ){

  $reply = array(
    'keyboard' => $keyb,
    'one_time_keyboard' => true,
    'resize_keyboard' => true,
    'selective' => true
  );

  return json_encode( $reply, true );
}

function curlGET( $url ) {

  $menuIthem = curl_init(
    trim( $url )
  );

  curl_setopt(
    $menuIthem,
    CURLOPT_RETURNTRANSFER,
    true
  );

  $res = explode(
    "\nDATA=",
    curl_exec(
      $menuIthem
    )
  );

  curl_close( $menuIthem );

  return json_decode( $res[1], true );
}

?>
dzNET
  • 930
  • 1
  • 9
  • 14
0

You used wrong format for inline keyboard, see following instance:

Awesome Telegram Bot

Sean Wei
  • 7,433
  • 1
  • 19
  • 39
  • 1
    My friend its inline button. its not my answer. I want `Miniaturize` buttons. not inline keyboard buttons i want Miniaturize keyboard button you can see in my code ! –  Oct 16 '17 at 14:46