Want to access response from wp_remote_post

I am calling api using wp_remote_post() method.I am getting below response from api

  Array
(
    [headers] => Array
        (
            [cache-control] => no-cache
            [pragma] => no-cache
            [content-length] => 100
            [content-type] => application/json
            [content-encoding] => deflate
            [expires] => -1
            [server] => Microsoft-IIS/8.5
            [x-aspnet-version] => 4.0.30319
            [date] => Fri, 27 May 2016 12:47:01 GMT
            [connection] => close
        )

    [body] => {"ResponseStatus":false,"ResponseData":null,"ErrorData":{"ErrorCode":"E0002","Error":"Email already registered.","ErrorDetail":"Email already registered."}}
    [response] => Array
        (
            [code] => 200
            [message] => OK
        )

    [cookies] => Array
        (
        )

    [filename] => 
)

I want to access all properties of above object

Read More

I am trying to access using below code

$res->ResponseStatus;

but it print nothing.

Related posts

Leave a Reply

1 comment

  1. $request = wp_remote_post( $url, array( 'body' => $args ) );
    
    if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) != 200 ) {
        return false;
    }
    $response = unserialize( wp_remote_retrieve_body( $request ) );