HamidR
HamidR

Reputation: 55

How do I write a telegram bot using 'inline_keyboard' (PHP)?

I'm using 'inline_keyboard' in my php telegram bot, but it is not working.
I tried the same code with 'replyKeyboardMarkup' and it worked perfectly; so guess there is something wrong with this part of the code but I can't find the problem.

$inlineKeyboardMarkup = [
  'inline_keyboard' => [
      [
        ['text'=>'text1','callback_data'=>$i],['text'=>'text2','callback_data'=>$i]
      ],
      [
        ['text'=>'start','callback_data'=>$i-(2*$i)]
      ]
    ]
  ];
 $inline_keyboard = json_encode($inlineKeyboardMarkup);

Upvotes: 1

Views: 4597

Answers (1)

hamed hossani
hamed hossani

Reputation: 1002

$keyboard = array( array( array('text'=>'text1','callback_data'=>"1") ,array('text'=>'text2','callback_data'=>"2") ), array( array('text'=>'start','callback_data'=>"4") ) ); $inlineKeyboardMarkup = array( 'inline_keyboard' => $keyboard ); $data["reply_markup"] = json_encode($inlineKeyboardMarkup);

Upvotes: 4

Related Questions