我正在 Woocommerce 中创建一个 webhook,但出现此错误:
Error: Delivery URL cannot be reached: A valid URL was not provided.
但是当我在 Postman 中测试这个 URL 时它运行良好,我不知道为什么会收到此错误,也许是端口?
您的错误消息意味着您的请求在第 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 );
这会将信息打印到您的站点错误日志中