wp_remote_request( string $url, array $args = array() ): array|WP_Error
Performs an HTTP request and returns its response.
Contents
Description
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()
See also
- WP_Http::request(): For information on default arguments.
Parameters
-
$url
string Required -
URL to retrieve.
-
$args
array Optional -
Request arguments.
Default:
array()
Return
array|WP_Error The response array or a WP_Error on failure.
headers
string[]Array of response headers keyed by their name.body
stringResponse body.response
arrayData about the HTTP response.code
int|falseHTTP response code.message
string|falseHTTP response message.
cookies
WP_HTTP_Cookie[]Array of response cookies.http_response
WP_HTTP_Requests_Response|nullRaw HTTP response object.
Source
File:
wp-includes/http.php
. View all referencesfunction wp_remote_request( $url, $args = array() ) { $http = _wp_http_get_object(); return $http->request( $url, $args ); }
Changelog
Changelog Version Description 2.7.0 Introduced.
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Send a Delete request with wp_remote_post
You can insert the DELETE method inside
wp_remote_request()
like this:Sample ConvertKit API call function using wp_remote_request()
What about calling this function? Well here’s another function which updates a contact’s email address/name