davykiash
davykiash

Reputation: 1804

Getting Response Body using Zend_http_Client

I am succesfully calling a REST API with the following code

$client = new Zend_Http_Client();
$client->setMethod(Zend_Http_Client::POST);
$client->setUri('http://www.example.com/api/type/');
$client->setParameterPost(array(
    'useremail'  => '******@*****.***',
    'apikey'   => 'secretkey',
    'description' => 'TEST WEB API',
    'amount'   => '5000.00'
    ));

However I would like to get both the header value-(201) and Response Body that are returned after the execution.

How do I proceed with that?

Upvotes: 3

Views: 9323

Answers (2)

Chali
Chali

Reputation: 1108

this should work...

 $client->setUri ( $image_source_urls );
 $response = $client->request ( 'GET' );
 $folder_content = $response->getBody ();

Upvotes: 1

Cody Caughlan
Cody Caughlan

Reputation: 32758

I am assuming that you're actually executing the request via:

$response = $client->request();

At that point all you need is in the $response object,

//Dump headers
print_r($response->headers);

//Dump body
echo $response->getBody();

Refer to the Zend_Http_Response docs at:

http://framework.zend.com/apidoc/1.10/

for more methods that are available.

Upvotes: 5

Related Questions