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_safe_remote_requestwp_remote_getwp_get_user_requestwp_create_user_requestwp_remote_post
引入
2.7.0
棄用
-

wp_remote_request是一個WordPress函式,用於向遠端伺服器發出HTTP請求。它支援GET、POST和其他HTTP方法,可以用來從遠端伺服器檢索資料或向遠端伺服器傳送資料。

執行一個HTTP請求並返回其響應。

還有其他可用的API函式,它們對HTTP方法進行了抽象:
– Default ‘GET’ for wp_remote_get()
– Default ‘POST’ for wp_remote_post()
– Default ‘HEAD’ for wp_remote_head()

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_remote_request( $url, $args = array() ) {
$http = _wp_http_get_object();
return $http->request( $url, $args );
}
function wp_remote_request( $url, $args = array() ) { $http = _wp_http_get_object(); return $http->request( $url, $args ); }
function wp_remote_request( $url, $args = array() ) {
	$http = _wp_http_get_object();
	return $http->request( $url, $args );
}

常見問題

FAQs
檢視更多 >