Reputation: 284
I'm trying to log my request before i do it, to know really what i'm sending example: I have this code:
$client = new Zend_Http_Client();
$client->setUri($uri);
$client->setConfig(array('timeout' => 30));
$client->setHeaders('Content-Type: application/xml');
$client->setMethod('POST');
$client->setParameterPost('PartnerID', 'xxx');
$client->setParameterPost('Password', 'XXXXXXXXX');
before i do the request i wanna know what i'm sending, something like that:
$request = json_encode($client);
Log::notice("Request: " . $request);
or:
Log::notice("Request: " . $client);
But doesn't work...
I can log the response like that:
$response = $client->request();
Log::notice("Response: " . $response);
Like that i can see the response json, but i wanna know the request that i'm doing.
Thank u all.
Upvotes: 1
Views: 2561
Reputation: 1561
You get the last request with function Zend_Http_Client->getLastRequest()
. Be aware that the function returns a string and you may have to add some code to fit it in a meaningful JSON output. Add the following to your code:
$request = $client->getLastRequest()
// make your changes to support JSON
Log::notice("Request: " . $request)
The function is also mentioned in the on-line documentation at Introduction - Zend_Http - Zend Framework - Accessing Last Request and Response.
Upvotes: 2