无法访问 WooCommerce Webhook URL

问题描述 投票:0回答:1

我正在 Woocommerce 中创建一个 webhook,但出现此错误:

Error: Delivery URL cannot be reached: A valid URL was not provided.

但是当我在 Postman 中测试这个 URL 时它运行良好,我不知道为什么会收到此错误,也许是端口?

woocommerce webhooks
1个回答
0
投票

您的错误消息意味着您的请求在第 275 行的“wp-includes/class-wp-http.php”中失败。

if ( empty( $url ) || empty( $parsed_url['scheme'] ) ) {
        $response = new WP_Error( 'http_request_failed', __( 'A valid URL was not provided.' ) );
        /** This action is documented in wp-includes/class-wp-http.php */
        do_action( 'http_api_debug', $response, 'response', 'WpOrg\Requests\Requests', $parsed_args, $url );
        return $response;
    }

您可以使用 http_api_debug 挂钩来记录有关调用失败原因的信息吗

例如

function log_http_api_debug( $response, $type, $class, $args, $url ) {
        error_log( 'HTTP API URL: ' . print_r( $url, true ) );
        error_log( 'HTTP API request: ' . print_r( $args, true ) );
        error_log( 'HTTP API response: ' . print_r( $response, true ) );
}
add_action( 'http_api_debug', 'log_http_api_debug', 10, 5 );

这会将信息打印到您的站点错误日志中

© www.soinside.com 2019 - 2024. All rights reserved.