TelegramBot / Api

Native PHP Wrapper for Telegram BOT API
MIT License
1.09k stars 324 forks source link

Wrong response from the webhook: 500 Internal Server #264

Closed 4dimarik closed 4 years ago

4dimarik commented 4 years ago

Версия 2.3.14 При отправке сообщения с InlineKeyboardMarkup

Fatal error: Uncaught ArgumentCountError: Too few arguments to function TelegramBot\Api\Types\Inline\InlineKeyboardMarkup::__construct(), 0 passed in /home/y/y4dima9q/topcraftbeer.ru/public_html/_gdntest2_bot/vendor/telegram-bot/api/src/BaseType.php on line 94 and exactly 1 expected in /home/y/y4dima9q/topcraftbeer.ru/public_html/_gdntest2_bot/vendor/telegram-bot/api/src/Types/Inline/InlineKeyboardMarkup.php:42 Stack trace:

0 /home/y/y4dima9q/topcraftbeer.ru/public_html/_gdntest2_bot/vendor/telegram-bot/api/src/BaseType.php(94): TelegramBot\Api\Types\Inline\InlineKeyboardMarkup->__construct()

1 /home/y/y4dima9q/topcraftbeer.ru/public_html/_gdntest2_bot/vendor/telegram-bot/api/src/BaseType.php(53): TelegramBot\Api\BaseType::fromResponse(Array)

2 /home/y/y4dima9q/topcraftbeer.ru/public_html/_gdntest2_bot/vendor/telegram-bot/api/src/BaseType.php(95): TelegramBot\Api\BaseType->map(Array)

3 /home/y/y4dima9q/topcraftbeer.ru/public_html/_gdntest2_bot/vendor/telegram-bot/api/src/BotApi.php(340): TelegramBot\Api\BaseType::from in /home/y/y4dima9q/topcraftbeer.ru/public_html/_gdntest2_bot/vendor/telegram-bot/api/src/Types/Inline/InlineKeyboardMarkup.php on line 42

require_once "vendor/autoload.php";
require_once "src/Config.php";
try {
    $bot = new \TelegramBot\Api\Client(Config::TELEGRAM_TOKEN);
    $bot->command('ping', function ($message) use ($bot) {
        $keyboard = new \TelegramBot\Api\Types\Inline\InlineKeyboardMarkup(
            [
                [
                    ['text' => 'link', 'url' => 'https://core.telegram.org']
                ]
            ]
        );
        $bot->sendMessage($message->getChat()->getId(), 'messageText', null, false, null, $keyboard);
        $bot->sendMessage($message->getChat()->getId(), 'pong!');
    });
    $bot->run();
} catch (\TelegramBot\Api\Exception $e) {
    $e->getMessage();
}
BoShurik commented 4 years ago

https://github.com/TelegramBot/Api/blob/master/src/BotApi.php#L316-L317

4dimarik commented 4 years ago

Что-то я не понял. sendMessage не поддерживает InlineKeyboardMarkup ? Пример кода из описания бота. Как отправить сообщение с InlineKeyboardMarkup ?

4dimarik commented 4 years ago

в 2.3.13 указанный выше код отрабатывает без ошибок

BoShurik commented 4 years ago

@4dimarik не нашел какой коммит все сломал?

4dimarik commented 4 years ago

Не думал об этом. Займусь как будет время.