V
V
Vyacheslav2022-01-25 12:45:03
Yii
Vyacheslav, 2022-01-25 12:45:03

Why is Telegram webHook giving 500 error in yii2?

Hello!

I’m trying to make a telegram webhook, I
set the link itself, the status on the link is OK
when I try to pull the link manually - the message arrives in the cart, everything is OK,
but when I send the message to the cart, I don’t receive a response, and the getWebhookInfo status shows 500:
Wrong response from the webhook: 500 Internal Server Error

getWebhookInfo:

{"ok":true,"result":{"url":"https://domain.ru/telegram/get","has_custom_certificate":false,"pending_update_count":39,"last_error_date":1643103534,"last_error_message":"Wrong response from the webhook: 500 Internal Server Error","max_connections":40,"ip_address":"xxx.xxx.xxx.xxx"}}


Controller code:
class TelegramController extends BaseController
{
  public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'get' => ['post'],
                ],
            ],
        ];
    }

  public function beforeAction($action)
  {            
      if ($action->id == 'get') {
            $this->enableCsrfValidation = false;
        }
        
        return parent::beforeAction($action);
  }

  public function actionGet()
  {
    TelegramBot::message('000000', 'ok');
  }
}


It feels like it should be allowed to accept POST from third-party sources, but I kind of turned off enableCsrfValidation, but it doesn’t work, something is missing. Tell me pliz)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question