On this page
wp_remote_request( string $url, array $args = array() ): array|WP_Error
Performs an HTTP request and returns its response.
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
$urlstring Required-
URL to retrieve.
$argsarray Optional-
Request arguments.
Default:
array()
Return
array|WP_Error The response array or a WP_Error on failure.
headersstring[]Array of response headers keyed by their name.bodystringResponse body.responsearrayData about the HTTP response.codeint|falseHTTP response code.messagestring|falseHTTP response message.
cookiesWP_HTTP_Cookie[]Array of response cookies.http_responseWP_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 ); }Related
Uses
Uses Description _wp_http_get_object() wp-includes/http.php Returns the initialized WP_Http Object
Used By
Used By Description wp_update_https_detection_errors() wp-includes/https-detection.php Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors.
WP_Http::handle_redirects() wp-includes/class-wp-http.php Handles an HTTP redirect and follows it if appropriate.
Changelog
Version Description 2.7.0 Introduced.
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_remote_request