WordPress at a glance
Home All Function Functions APIs HTTP API

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.

  • See: wp_remote_request() For more information on the response array format.
  • See: WP_Http::request() For default arguments information.
Works based on: _wp_http_get_object()

No Hooks.


WP_Error/Array. The response or WP_Error on failure.


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

Code of wp safe remote request: wp-includes/http.php WP 5.2.1

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

Related Functions

From tag: HTTP API (curl remote)

No comments
    Hello, !     Log In . Register