TelegramBot / Api

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

Ошибка при запуске #387

Closed vesh95 closed 1 year ago

vesh95 commented 1 year ago

telegram-bot/api php 8.2

try {
            $client = new Client($this->botKey);
            $client->on(function (Update $update) use ($client) {
                $message = $update->getMessage();
            }, fn() => true);

            $client->run();
        } catch (InvalidJsonException $e) {
            return $e->getCode();
        }

Трейс:


2023-01-07T17:13:26.237520343Z Fatal error: Uncaught TelegramBot\Api\InvalidJsonException: Syntax error in /app/vendor/telegram-bot/api/src/BotApi.php:304
2023-01-07T17:13:26.237525022Z Stack trace:
2023-01-07T17:13:26.237526356Z #0 /app/vendor/telegram-bot/api/src/Client.php(141): TelegramBot\Api\BotApi::jsonValidate('', true)
***
***
2023-01-07T17:13:26.237530419Z #3 {main}
2023-01-07T17:13:26.237531568Z   thrown in /app/vendor/telegram-bot/api/src/BotApi.php on line 304
BoShurik commented 1 year ago

It's a webhook and it must be called by telegram itself. $client->run() method expects php://input contains data from telegram