W3cubDocs

/WordPress

wp_remote_request( string $url, array $args = array() ): array|WP_Error

Performs an HTTP request and returns its response.

Description

There are other API functions available which abstract away the HTTP method:

See also

Parameters

$urlstringrequired
URL to retrieve.
$argsarrayoptional
Request arguments.
See WP_Http::request() for information on accepted arguments.

Default:array()

Return

array|WP_Error The response array or a WP_Error on failure.
See WP_Http::request() for information on return value.

Source

function wp_remote_request( $url, $args = array() ) {
	$http = _wp_http_get_object();
	return $http->request( $url, $args );
}

Changelog

Version Description
2.7.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_remote_request