A WordPress-centric search engine for devs and theme authors



wp_safe_remote_request ›

Since3.6.0
Deprecatedn/a
wp_safe_remote_request ( $url, $args = array() )
Parameters: (2)
  • (string) $url Site URL to retrieve.
    Required: Yes
  • (array) $args Optional. Request arguments. Default empty array.
    Required: No
    Default: array()
See:
Returns:
  • (WP_Error|array) The response or WP_Error on failure.
Defined at:
Codex:

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.



Source

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