3

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?

davykiash
  • 1,796
  • 5
  • 27
  • 60

2 Answers2

5

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.

Cody Caughlan
  • 32,456
  • 5
  • 63
  • 68
1

this should work...

 $client->setUri ( $image_source_urls );
 $response = $client->request ( 'GET' );
 $folder_content = $response->getBody ();
Chali
  • 1,100
  • 3
  • 12
  • 18