Title: wp_remote_retrieve_response_message
Published: April 25, 2014
Last modified: August 20, 2026

---

# wp_remote_retrieve_response_message( array|WP_Error $response ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#user-contributed-notes)

Retrieves only the response message from the raw response.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#description)󠁿

Will return an empty string if incorrect parameter value is given.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#parameters)󠁿

 `$response`array|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
required

HTTP response.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#return)󠁿

 string The response message. Empty string if incorrect parameter given.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#source)󠁿

    ```php
    function wp_remote_retrieve_response_message( $response ) {
    	if ( is_wp_error( $response ) || ! isset( $response['response'] ) || ! is_array( $response['response'] ) ) {
    		return '';
    	}

    	return $response['response']['message'];
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/http.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/http.php#L300)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/http.php#L300-L306)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#related)󠁿

| Uses | Description | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

| Used by | Description | 
| [WP_AI_Client_HTTP_Client::create_psr_response()](https://developer.wordpress.org/reference/classes/wp_ai_client_http_client/create_psr_response/)`wp-includes/ai-client/adapters/class-wp-ai-client-http-client.php` |

Creates a PSR-7 response from a WordPress HTTP response.

  | 
| [wp_get_https_detection_errors()](https://developer.wordpress.org/reference/functions/wp_get_https_detection_errors/)`wp-includes/https-detection.php` |

Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors.

  | 
| [WP_Site_Health::check_for_page_caching()](https://developer.wordpress.org/reference/classes/wp_site_health/check_for_page_caching/)`wp-admin/includes/class-wp-site-health.php` |

Checks if site has page cache enabled or not.

  | 
| [WP_Site_Health::get_test_rest_availability()](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_rest_availability/)`wp-admin/includes/class-wp-site-health.php` |

Tests if the REST API is accessible.

  | 
| [download_url()](https://developer.wordpress.org/reference/functions/download_url/)`wp-admin/includes/file.php` |

Downloads a URL to a local temporary file using the WordPress HTTP API.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/?output_format=md#comment-content-1611)
 2.   [Drew Jaynes](https://profiles.wordpress.org/drewapicture/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_message/#comment-1611)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_remote_retrieve_response_message%2F%23comment-1611)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_remote_retrieve_response_message%2F%23comment-1611)
 4. **Make Request and Display Error**
 5.     ```php
        /**
         * Get movie information from IMDB.
         *
         * @param string $title Title of the movie
         * @param int $id IMDB ID of the movie
         * @return string|WP_Error Returns the contents of the response on success, WP_Error on failure
         */
        function wcpdx_get_movie( $title, $id = 0 ) {
    
        	// Collect the args
        	$params = array(
        		'i' => absint( $id ),
        		't' => sanitize_text_field( $title )
        	);
    
        	// Generate the URL
        	$url = 'http://www.imdbapi.com/';
        	$url = add_query_arg( $params, esc_url_raw( $url ) );
    
        	// Make API request
        	$response = wp_remote_get( esc_url_raw( $url ) );
    
        	// Check the response code
        	$response_code       = wp_remote_retrieve_response_code( $response );
        	$response_message = wp_remote_retrieve_response_message( $response );
    
        	if ( 200 != $response_code && ! empty( $response_message ) ) {
        		return new WP_Error( $response_code, $response_message );
        	} elseif ( 200 != $response_code ) {
        		return new WP_Error( $response_code, 'Unknown error occurred' );
        	} else {
        		return wp_remote_retrieve_body( $response );
                }
        }
    
        // Make request
        $movie = 'Hairspray';
        $response = wcpdx_get_movie( $movie );
    
        // Print error if error, otherwise print information
        if ( is_wp_error( $response ) ) {
        	echo 'The following error occurred when contacting IMDB: ' . wp_strip_all_tags( $response->get_error_message() );
        } else {
        	$data = json_decode( $response );
        	echo 'The movie ' . esc_html( $data['Title'] ) . ' was released in ' . absint( $data['Year'] ) . '.';
        }
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_remote_retrieve_response_message%2F%3Freplytocom%3D1611%23feedback-editor-1611)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_remote_retrieve_response_message%2F)
before being able to contribute a note or feedback.