WordPress at Your Fingertips

wp_safe_remote_request() WP 1.0

Retrieve the raw response from a safe HTTP request.

This function is ideal when the HTTP request is being made to an arbitrary URL. The URL is validated to avoid redirection and request forgery attacks.

No Hooks.


Array|WP_Error. The response or WP_Error on failure.


wp_safe_remote_request( $url, $args );
$url(string) (required)
URL to retrieve.
Request arguments.
Default: empty array



Since 3.6.0 Introduced.

Code of wp_safe_remote_request() WP 5.7.2

function wp_safe_remote_request( $url, $args = array() ) {
	$args['reject_unsafe_urls'] = true;
	$http                       = _wp_http_get_object();
	return $http->request( $url, $args );

From tag: HTTP API (curl remote)

No comments
    Log In