Retrieve the raw response from a safe HTTP request using the GET method.
Description
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 also
- wp_remote_request(): For more information on the response array format.
- WP_Http::request(): For default arguments information.
Parameters
$url
stringrequired- URL to retrieve.
$args
arrayoptional- Request arguments.
See WP_Http::request() for information on accepted arguments.Default:
array()
Source
function wp_safe_remote_get( $url, $args = array() ) {
$args['reject_unsafe_urls'] = true;
$http = _wp_http_get_object();
return $http->get( $url, $args );
}
Changelog
Version | Description |
---|---|
3.6.0 | Introduced. |
Retrieving and decoding json file –
Request with authorization parameters