wp_remote_request() – Performs an HTTP request and returns its response.

You appear to be a bot. Output may be restricted

Description

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()

Usage

$array|WP_Error = wp_remote_request( $url, $args );

Parameters

$url
( string ) required – URL to retrieve.
$args
( array ) optional – Optional. Request arguments. Default empty array. See WP_Http::request() for information on accepted arguments.
$headers
( string[] ) optional – Array of response headers keyed by their name.
$body
( string ) optional – Response body.
$response
( array ) optional – { Data about the HTTP response.
$code
( int|false ) optional – HTTP response code.
$message
( string|false ) optional – HTTP response message. }
$cookies
( WP_HTTP_Cookie[] ) optional – Array of response cookies.
$http_response
( WP_HTTP_Requests_Response|null ) optional – Raw HTTP response object. }

Returns

array|WP_Error { The response array or a WP_Error on failure.

Source

File name: wordpress/wp-includes/http.php
Lines:

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

 View on GitHub View on Trac