Search code examples
phptelegram-botphp-telegram-bot

Telegram Bot - Cannot remove custom keyboard using PHP


please help me. I added a custom keyboard via reply_markup like this:

        $reply_markup = array(
            'keyboard' => array(
                array(
                    array( 
                        'text' => 'Click here to upload contact & validate it',
                        'request_contact' => true
                    )
                )
            ),
            'one_time_keyboard' => true,
            'resize_keyboard' => true
        );

        $reply_markup = json_encode($reply_markup);

        API_URL."sendmessage?chat_id=".$chatID."&text=".urlencode($reply)."&reply_markup=".urlencode($reply_markup);

it is working fine. but now I need to remove the custom keyboard. I tried like this:

        $reply_markup = array(
            'remove_keyboard' => true
        );

        API_URL."sendmessage?chat_id=".$chatID."&text=".urlencode($reply)."&reply_markup=".urlencode($reply_markup);

it is not working. the custom keyboard only hidden, not removed. By the way, I am using PHP 7.

Please help. Thank you in advance


Solution

  • so today I found out, my actual code missing one line of code. it can be seen below, the bold part.

            $reply_markup = array(
                'remove_keyboard' => true
            );
    

    $reply_markup = json_encode($reply_markup);

            API_URL."sendmessage?chat_id=".$chatID."&text=".urlencode($reply)."&reply_markup=".urlencode($reply_markup);