error Call to a member function getChat() on null in package t telegram-bot-sdk

559 Views Asked by At

I'm using the data from telegrams received Webhook but I am faced with this error Webhook tested properly set.

enter image description here

In your opinion, what is the problem?

This is my code:

Route :

Route::post('setwebhook','BotController@setWebhook');
Route::post('updates','BotController@updates');

BotController :

public function setWebhook()
{
    $res = Telegram::setWebhook([
        'url' => 'https://example.com/telegram-sdk/public/updates'
    ]);
    return $res;
}
public function updates()
{
    $update = Telegram::getWebhookUpdates();
    $chat_id = $update->getMessage()->getChat()->getId();
    $text = $update->getMessage()->getText();
    $name = $update->getMessage()->getChat()->getFirstName();
    if ($text == '/start') {
        Telegram::sendMessage([
            'chat_id' => $chat_id,
            'text' => 'Hello World'
        ]);
    }
}
0

There are 0 best solutions below