On this page
wp_remote_fopen( string $uri ): string|false
HTTP request for URI to retrieve content.
Description
See also
Parameters
$uristring Required-
URI/URL of web page to retrieve.
Return
string|false HTTP content. False on failure.
More Information
Source
File: wp-includes/functions.php. View all references
function wp_remote_fopen( $uri ) {
$parsed_url = parse_url( $uri );
if ( ! $parsed_url || ! is_array( $parsed_url ) ) {
return false;
}
$options = array();
$options['timeout'] = 10;
$response = wp_safe_remote_get( $uri, $options );
if ( is_wp_error( $response ) ) {
return false;
}
return wp_remote_retrieve_body( $response );
}
Related
Uses
| Uses | Description |
|---|---|
| wp_safe_remote_get() wp-includes/http.php | Retrieve the raw response from a safe HTTP request using the GET method. |
| wp_remote_retrieve_body() wp-includes/http.php | Retrieve only the body from the raw response. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 1.5.1 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_remote_fopen