Jod*_*992 1 php post json webhooks sendgrid
我正在使用基于 SendGrid API v3 的 Webhook。Webhook 完全设置了 SendGrid 发布到的端点,但我需要能够接收解析的数据并将其存储在使用 PHP 的数据库中,但不知道如何做到这一点。
我在启动数据检索或 POST 之前使用过 API,但是当 API 服务器是一个 POST 时,我如何捕获通过 Webhook 端点解析的数据?到目前为止,我有一些简单的方法,但我真的不清楚如何解决这个问题:
<?php
$json = file_get_contents('https://example.com/webhook.php');
$json_decoded = json_decode($json, true);
$var_dump(json_decoded);
?>
Run Code Online (Sandbox Code Playgroud)
我曾尝试向主持人发送多封电子邮件,但每次拨打此电话时我都会返回NULL.
尝试使用此示例中的代码。这将为您提供要解码的原始 HTTP 请求正文字节。
<?php
$data = file_get_contents("php://input");
$events = json_decode($data, true);
foreach ($events as $event) {
// Here, you now have each event and can process them how you like
process_event($event);
}
?>
Run Code Online (Sandbox Code Playgroud)
更多信息 php://input
| 归档时间: |
|
| 查看次数: |
10422 次 |
| 最近记录: |