首页 文章

如何从WooCommerce产品CRUD webhook获取正确的数据?

提问于
浏览
-1

我正在创建一个能够从许多WooCommerce网站接收webhooks的系统 .

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

但是,当对某个WooCommerce实例中的产品执行CRUD操作时,webhook内容似乎不正确:

  • 它不包含任何有效载荷,

  • 它不包含任何识别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.

1 回答

  • 0

    我发现要传递webhook需要两件事(来自WooCommerce docs的未知):

    • 必须安装并启用CURL PHP扩展 .

    • 这个webhooks由Wordpress cron作业( wp-cron.php )提供,在我们的开发环境中它没有被设置 .

    正如this issue中所建议的那样,检查每个webhook日志也有帮助,因为空日志表明设置中存在问题,如前所述(CURL / Cron等) .

相关问题