Search code examples
phplaraveltelegramtelegram-bottelebot

In a laravel telegram bot project since upgrading westacks/telebot package to version 2.1 i've been getting this error. any ideas what the problem is?


I have a laravel telegram-bot project and it handles telegram updates like this in api.php;

Route::post('/', function (Request $request) {
    \WeStacks\TeleBot\Laravel\TeleBot::handleUpdate(
        Update::create(json_decode($request->getContent()))
    );
});

but since I upgraded telebot to 2.1 no matter what I do it does not run the update handlers and gives the error.

local.ERROR: WeStacks\TeleBot\Helpers\Type::castMany(): Argument #1 ($values) must be of type iterable, stdClass given.

any ideas what the problem might be?


Solution

  • Pass parameters as array:

    Route::post('/', function (Request $request) {
        \WeStacks\TeleBot\Laravel\TeleBot::handleUpdate(
            Update::create(json_decode($request->getContent(), true))
        );
    });