如何从 WooCommerce 中的 webhook 为客户获取变量

How to get variable for a customer from a webhook in WooCommerce

我正在使用 WooCommerce 订阅,并为客户取消订阅创建了一个网络挂钩...

我想在此事件发生时将 MySQL 数据库记录从 'Publish' 更新为 'Delete'。我在交付 URL.

中为其创建了一个新页面等
FORM/POST PARAMETERS

webhook_id: 4099
HEADERS

Cf-Connecting-Ip: 212.227.29.24
Content-Length: 15
Total-Route-Time: 0
Host: requestb.in
Accept: */*
Cf-Visitor: {"scheme":"https"}
Accept-Encoding: gzip
Referer: https://requestb.in/sqwf1tsq
User-Agent: WooCommerce/3.1.2 Hookshot (WordPress/4.8.1)
Connect-Time: 1
Content-Type: application/x-www-form-urlencoded
Cf-Ray: 39d5a75dc8980f45-FRA
X-Request-Id: e1b16cd7-fb41-471b-9c47-dce0dd7260cc
Cf-Ipcountry: DE
Via: 1.1 vegur
Connection: close
RAW BODY

webhook_id=4099

但是...如何从 Web 挂钩负载中获取任何变量?它是如此令人困惑(这里是新手!)。我想获取用户名或一个名为 'barcode' 的变量,它存储在每个 user/customer 中,然后我可以在单独的数据库中识别并进行更改。

希望这是有道理的..!

不胜感激, 非常感谢!!

您响应 webhook 的函数应该侦听 php 输入流。

$input = @file_get_contents("php://input");
var_dump($input); //this will output everything sent to your webhook

从这里,您可以看到您想要获取哪些属性。