尝试使用Laravel构建Telegram机器人,并收到此错误ReplyWithKeyBoardMethod不可用

时间:2018-12-14 17:37:50

标签: php laravel telegram-bot

从电报Bot sdk https://telegram-bot-sdk.readme.io/v2.0/docs/keyboards中获取此错误,我想使用ReplyKeyboardMarkup方法获取此错误

production.ERROR: Method [ReplyKeyboardMarkup] does not exist. {"exception":"[object] (BadMethodCallException(code: 0): Method [ReplyKeyboardMarkup] does not exist. at /app/vendor/irazasyed/telegram-bot-sdk/src/Api.php:98)

现在我知道这应该是一种类型,而不是一种方法,但是解决方法是有人可以提供帮助的问题。

这就是我所做的

$reply_markup = \Telegram::replyKeyboardMarkup([
            'keyboard' => $keyboard, 
            'resize_keyboard' => true, 
            'one_time_keyboard' => true
        ]);

$response = \Telegram::sendMessage([
            'chat_id' => 'CHAT_ID', 
            'text' => 'Hello World', 
            'reply_markup' => $reply_markup
        ]);

1 个答案:

答案 0 :(得分:0)

实际上不建议使用replyKeyboardMarkup,因此现在使用的是use use Telegram\Bot\Keyboard\Keyboard;,然后

    Keyboard::make([
        'keyboard' => $keyboard, 
        'resize_keyboard' => true, 
        'one_time_keyboard' => true
    ]);