telegram-bot-sdk icon indicating copy to clipboard operation
telegram-bot-sdk copied to clipboard

The Telegram::getWebhookUpdate() result always empty array []

Open untillnesss opened this issue 2 years ago • 2 comments
trafficstars

PHP version

PHP 8.2

irazasyed/telegram-bot-sdk version

versions : * v3.13.0

Laravel version (if any)

versions : * v10.25.2

Code To Reproduce the bug

image

I have code like the one above, namely the code to run the webhook sent by Telegram, but the result is always an empty array.

image

I have checked the Telegram Bot token many times, there is nothing wrong, it is correct, and I have installed the webhook URL properly.

Is there anything I missed?

Error stacktrace (if any)

No response

untillnesss avatar Oct 28 '23 12:10 untillnesss

I had the same problem) Steps to fix:

  1. Require psr-7 requests, from src: https://laravel.com/docs/10.x/requests#psr7-requests
  2. Pass request, like this:
public function __invoke(ServerRequestInterface $request)
{
    $update = Telegram::getWebhookUpdate(request: $request);
}

Freezon avatar Nov 27 '23 05:11 Freezon

doesnt work anyway. even installing psr7 request interface. nothing at all!!!

riettotek avatar Feb 02 '24 16:02 riettotek

Method signature is getWebhookUpdate(bool $shouldDispatchEvents = true, ?RequestInterface $request = null).

Behind the scene it relies on file_get_contents('php://input') to retrieve the REQUEST body sent from Telegram, so you need to use this method directly within your webhook where this gets invoked or if you wish to wrap it inside other classes/methods, then pass the PSR7 Request.

irazasyed avatar Mar 11 '24 03:03 irazasyed