Lui*_*ado 5 wordpress webhooks woocommerce
我正在设置WooCommerce以在创建订单时触发webhook.我已将webhook的URL设置为我们为此目的设置的本地Web API的URL:
http://localhost:3000/store/orders/new
Run Code Online (Sandbox Code Playgroud)
WooCommerce确实使用正确的数据有效负载触发webhook,但在webhook的日志中报告请求失败:
Status: HTTP http_request_failed Es wurde keine gültige URL übermittelt.: Array
Run Code Online (Sandbox Code Playgroud)
从德语翻译,意思是"没有通过有效的URL"
然后我将URL更改为我们的API(https://xxx.azurewebsites.net/store/order/new)的面向Web的部署,并且API 收到了webhook而没有任何问题.
我不确定WC webhook是否不适合使用自定义端口的网址(在我的情况下,端口3000),所以我想询问是否这是真的问题以及是否有办法制作WC webhooks与localhost开发环境一起玩得很好.
Fla*_*oia 15
我在文件末尾插入以下代码后解决了这个问题:wp-content/themes/MYTHEME/functions.php
function allow_unsafe_urls ( $args ) {
$args['reject_unsafe_urls'] = false;
return $args;
} ;
add_filter( 'http_request_args', 'allow_unsafe_urls' );
Run Code Online (Sandbox Code Playgroud)
对于 WooCommerce 3.3.5 版,Bjorn 的解决方案似乎不起作用。
就我而言,我必须编辑文件wp-content/plugins/woocommerce/includes/class-wc-webhook.php:185, method deliver。
注释该wp_safe_remote_request方法,而是使用不安全的 http 请求方法。
// Webhook away!
$http_call = _wp_http_get_object();
$response = $http_call->request( $this->get_delivery_url(), $http_args );
//$response = wp_safe_remote_request( $this->get_delivery_url(), $http_args );
Run Code Online (Sandbox Code Playgroud)
小智 6
它不是自定义端口,而是本地主机。
在 wp-includes/http.php wp_http_validate_url() 中有一个检查,它拒绝所有类型的本地 IP,除非特别允许 http_request_host_is_external 上的过滤器返回 true...
干杯,比约恩
| 归档时间: |
|
| 查看次数: |
2499 次 |
| 最近记录: |