如何读取webhooks发送的数据? [英] How to read data sent by webhooks?

查看:25
本文介绍了如何读取webhooks发送的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有最新的 woocommerce 插件,我必须为我的 URL 之一设置一个 webhook.但是我无法在 $_REQUEST 和 $input = file_get_contents("php://input"); 中读取它.

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");.

推荐答案

$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

这篇关于如何读取webhooks发送的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆