wp_remote_retrieve_body() WordPress Function

The wp_remote_retrieve_body() function is used to retrieve the body of a remote request. This function is useful for retrieving the content of a remote URL, such as a webpage or an API endpoint. The body of the request is returned as a string.

wp_remote_retrieve_body( array|WP_Error $response ) #

Retrieve only the body from the raw response.


Parameters

$response

(array|WP_Error)(Required)HTTP response.


Top ↑

Return

(string) The body of the response. Empty string if no body or incorrect parameter given.


Top ↑

Source

File: wp-includes/http.php

function wp_remote_retrieve_body( $response ) {
	if ( is_wp_error( $response ) || ! isset( $response['body'] ) ) {
		return '';
	}

	return $response['body'];
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.