wp_remote_request( string $url, array $args = array() )
Performs an HTTP request and returns its response.
Contents
Description 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 See also
- WP_Http::request(): For information on default arguments.
Parameters Parameters
- $url
-
(string) (Required) URL to retrieve.
- $args
-
(array) (Optional) Request arguments.
Default value: array()
Return Return
(WP_Error|array) The response array or a WP_Error on failure.
- 'headers'
(string[]) Array of response headers keyed by their name. - 'body'
(string) Response body. - 'response'
(array) Data about the HTTP response.- 'code'
(int|false) HTTP response code. - 'message'
(string|false) HTTP response message.
- 'code'
- 'cookies'
(WP_HTTP_Cookie[]) Array of response cookies. - 'http_response'
(WP_HTTP_Requests_Response|null) Raw HTTP response object.
Source Source
File: wp-includes/http.php
function wp_remote_request( $url, $args = array() ) { $http = _wp_http_get_object(); return $http->request( $url, $args ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.7.0 | Introduced. |
User Contributed Notes 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()
Expand full source codeCollapse full source code
What about calling this function? Well here’s another function which updates a contact’s email address/name
Expand full source codeCollapse full source code