我正在开发webhook以注意订单何时更新。
我的webhook功能如下所示:
public function webhook(Request $request) {
if(!empty(Request::header('x-wc-webhook-delivery-id'))) {
$head = Request::header('x-wc-webhook-source');
$site = preg_replace('{/$}', '', $head);
$webhookId = Request::header('x-wc-webhook-id');
$deliveryId = Request::header('x-wc-webhook-delivery-id');
$this->webhookOrders($site, $webhookId, $deliveryId);
}
}
因此它将触发webhookOrders函数,该函数仅通过WebhookId&获取更新的订单。 deliveryId:
$delivery = $woocommerce->get('webhooks/'.$webhookId.'/deliveries/'.$deliveryId);
虽然奇怪的是,当我尝试通过webhook访问此get请求时,它显示我一个空的响应:
Array
(
[id] => 559
[duration] =>
[summary] =>
[request_method] =>
[request_url] => https://<my_platform>/api/v1/orders/create
[request_headers] =>
[request_body] =>
[response_code] =>
[response_message] =>
[response_headers] =>
[response_body] =>
[date_created] => 2018-02-28T10:48:05
[_links] => Array
(
[self] => Array
(
[0] => Array
(
[href] => https://<my_woo_site>/wp-json/wc/v1/webhooks/0/deliveries/559
)
)
[collection] => Array
(
[0] => Array
(
[href] => https://<my_woo_site>/wp-json/wc/v1/webhooks/0/deliveries
)
)
[up] => Array
(
[0] => Array
(
[href] => https://<my_woo_site>/wp-json/wc/v1/webhooks/0
)
)
)
)
在Woocommerce管理面板中,它向我显示有内容:
另外,令我疯狂的是,当我访问webhook外的URL时,它会向我显示内容。并且日志文件没有显示任何错误。
希望有人知道这个问题。谢谢!
答案 0 :(得分:1)
发现问题:
不再记录交货。
@deprecated 3.3.0 Webhooks交付日志现在使用日志系统。