Telegram Bot custom keyboard in PHP

穿精又带淫゛_ 提交于 2019-11-30 06:45:47

The docs seem to indicate you need to provide the reply_markup parameter as a JSON serialised object... kinda stupid for a form POST endpoint:

$replyMarkup = array(
    'keyboard' => array(
        array("A", "B")
    )
);
$encodedMarkup = json_encode($replyMarkup);
$content = array(
    'chat_id' => <chat_id>,
    'reply_markup' => $encodedMarkup,
    'text' => "Test"
);

Does this one work?

   $keyboard = array(array("[Destaques]","[Campinas e RMC]","[esportes]"));
   $resp = array("keyboard" => $keyboard,"resize_keyboard" => true,"one_time_keyboard" => true);
   $reply = json_encode($resp);
   $url = $GLOBALS[website]."/sendmessage?chat_id=".$chatId."&text=oi&reply_markup=".$reply;
    file_get_contents($url);

This code works fine!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!