irazasyed / telegram-bot-sdk

🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
https://telegram-bot-sdk.com
BSD 3-Clause "New" or "Revised" License
3.04k stars 671 forks source link

Wrong response from the webhook: 403 Forbidden #1112

Closed NihilIF closed 8 months ago

NihilIF commented 9 months ago

PHP version

8.1

irazasyed/telegram-bot-sdk version

3.13

Laravel version (if any)

10.44.0

Code To Reproduce the bug

StartCommand.php

namespace App\Console\Commands\Telegram;

use Telegram\Bot\Commands\Command;

class StartCommand extends Command { protected string $name = 'start'; protected string $description = 'Iniciar bot para presentarse';

public function handle()
{
    $this->replyWithMessage([
        'parse_mode' => 'HTML',
        'text' => mb_convert_encoding('Hola', 'UTF-8', mb_list_encodings())
    ]);
}

}

My controller function

public function activarWebhook(Request $request) { $update = Telegram::commandsHandler(true); return 'ok'; }

my route in api.php

Route::post('/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxl/webhook', [TelegramControlador::class, 'activarWebhook']);

Error stacktrace (if any)

Getting a 403 error from my server in CPanel when I try to run a command from my telegram bot. I don't understand what's happening, my route is in api.php so I shouldn't need the CSRF

kg-bot commented 9 months ago

Can you share code from your app/Http/Kernel.php file?

NihilIF commented 8 months ago

`<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel { /**