我正在运行带有WooCommerce结帐的WordPress网站。在结帐页面上,我使用webhook woocommerce_thankyou 作为代码的登机点。此时,我正在从新订单中选择一些数据,以通过Webhook将数据发送到另一个网站。 我在自定义WordPress插件上集成了代码。此刻,webhook给了我以下错误:“ DigiMember-Webhook签出(#1):电子邮件地址不会以GET-或POST-Parameter的形式发送。”
可能是什么问题?
<?php
function test ($order_id) {
?>
<span>
woocommerce_thankyou
<?php echo $order_id;
$order=wc_get_order($order_id);
echo $order->get_meta('digi_first_name');
echo $order->get_meta('digi_last_name');
echo $order->get_meta('digi_email');
?>
</span>
<?php
//The url you wish to send the POST request to
$url = 'https://traumjob-campus.de/member?dm_webhook=1_DCqtx6Xre1oM7tuKyon5rVzAIUWvVVXofMqTRQjE9JVDgf7gLI3M198bIeD5';
//The data you want to send via POST
$fields = [
'digi_first_name' => 'user',
'digi_last_name' => 'test',
'digi_email' => 'test@user.de'
];
//url-ify the data for the POST
$fields_string = http_build_query($fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//So that curl_exec returns the contents of the cURL; rather than echoing it
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
//execute post
$result = curl_exec($ch);
echo $result;
?>