How to read data sent by webhooks?

2019-02-16 04:43发布

I have the latest woocommerce plugin, and I have to set a webhook to one of my URL. But I am not able to read it in my $_REQUEST and nor in $input = file_get_contents("php://input");.

1条回答
贼婆χ
2楼-- · 2019-02-16 05:08
$webhookContent = "";

$webhook = fopen('php://input' , 'rb');
while (!feof($webhook)) {
    $webhookContent .= fread($webhook, 4096);
}
fclose($webhook);
mail('mail@yourdomain.com', 'test - hook', $webhookContent);

This is all it took. It will send all the body to your email

查看更多
登录 后发表回答