2017-06-13 51 views
-1

我正在创建一个能够接收来自许多WooCommerce网站的webhooks的系统。如何从WooCommerce产品CRUD webhook获取正确的数据?

我还创建了一堆WooCommerce实例,并将它们配置为在发生产品CRUD操作时webhook地址https://requestb.in/qivtf4qi

然而,在WooCommerce实例的一个执行过的产品的CRUD操作时,网络挂接内容似乎不正确:

  • 它不包含任何有效载荷,
  • 它不包含任何识别webhook来自哪里(实例域等)的方式,除了原始服务器IP(如果实例被移动或水平调整,则很不可靠)。

什么是WooCommerce交付正确 webhook数据的正确方法?

See an example of what gets sent on product update: no way to identify the instance, no content so quite pointless as we would have to query all the products to find out which one was updated

See how each WooCommerce instance is configured to deliver hooks to that single service we're building.

See how the WooCommerce API docs say that the webhook payload should actually carry the resource like if it was modified using the REST API. They also mention a header, X-WC-Webhook-Source, that should contain the source domain.

回答

0

我发现了两件事情需要(未知来自WooCommerce文档)用于交付的网络挂接:

  • 卷曲的PHP扩展有被安装和启用。
  • webhooks通过WordPress的cron作业(wp-cron.php)交付,并且在我们的开发环境中没有设置。

如图this issue建议的,检查每个网络挂接日志有助于为好,作为一个空的日志建议在像前面描述(CURL /克龙等)的设置有问题。