Ошибка вызова функции-члена getChat() для null в пакете t telegram-bot-sdk
Я использую данные из телеграмм, полученных Webhook, но столкнулся с этой ошибкой, провереннойWebhook.
По вашему мнению, в чем проблема?
Это мой код:
Маршрут:
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'
]);
}
}