wp_safe_remote_request

函数


wp_safe_remote_request ( $url, $args = array() )
参数
  • (string)
    $url
    URL to retrieve.
    Required:
  • (array)
    $args
    Optional. Request arguments. Default empty array.
    Required:
    Default: array()
返回值
  • (array|WP_Error) The response or WP_Error on failure.
相关
  • wp_remote_request()
  • WP_Http::request()
定义位置
  • wp-includes/http.php
    , line 44
引入
3.6.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.

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