Laravel webhook 客户端在 Whatsapp Webhook url 上出现错误 405

问题描述 投票:0回答:3

我尝试在 Whatsapp Cloud 中使用 Laravel 进行 Webhook,但它显示此错误

脸书错误

1

并在 ngrok 中显示此错误

Ngrok 错误

2

我使用 https://github.com/spatie/laravel-webhook-client 作为 webhook

laravel facebook webhooks whatsapp
3个回答
1
投票

从根本上来说,Whatsapp webhook 服务器不会接受 Ngrok 作为回调 URL 公开的链接。

因为此类网址已被识别为恶意和/或滥用。

您需要在服务器上使用您的脚本,并使用具有经过认证的 ssl 的有效域作为 Webhook

https://example.com/webhook

https://listener.example.com/webhook


0
投票

您只需返回

hub_challenge
。 这对我有用
return $req['hub_challenge'];


0
投票
[HttpGet("webhook")]
public IActionResult Get(string hub_mode, string hub_challenge, string hub_verify_token)
{
      // You can access the query settings here and do whatever you need.

      // For example, you can check if hub_verify_token equals an expected value:
      if (hub_verify_token == "123")
      {
          return Ok(hub_challenge); // Returns hub_challenge as a response if the token is correct.
      }
      other
      {
          return BadRequest("Invalid Token");
      }
}
© www.soinside.com 2019 - 2024. All rights reserved.