wp_remote_request

函数


wp_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 array or a WP_Error on failure. @type string[] $headers Array of response headers keyed by their name. @type string $body Response body. @type array $response { Data about the HTTP response. @type int|false $code HTTP response code. @type string|false $message HTTP response message. } @type WP_HTTP_Cookie[] $cookies Array of response cookies. @type WP_HTTP_Requests_Response|null $http_response Raw HTTP response object. }
相关
  • WP_Http::request()
定义位置
  • wp-includes/http.php
    , line 143
引入
2.7.0
弃用

Performs an HTTP request and returns its response.

There are other API functions available which abstract away the HTTP method:

– Default ‘GET’ for wp_remote_get()
– Default ‘POST’ for wp_remote_post()
– Default ‘HEAD’ for wp_remote_head()

function wp_remote_request( $url, $args = array() ) {
	$http = _wp_http_get_object();
	return $http->request( $url, $args );
}