2014-10-07 46 views
0

我試圖登錄我的要求我這樣做之前,要真正知道我要送例如: 我有這樣的代碼:如何記錄一個Zend_Http_Client要求

$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'); 

我做的請求之前我想知道我要送,這樣的事情:

$request = json_encode($client); 
Log::notice("Request: " . $request); 

或:

Log::notice("Request: " . $client); 

但沒有按「T工作...

我可以登錄這樣的迴應:

$response = $client->request(); 
Log::notice("Response: " . $response); 

喜歡,我可以看到響應JSON,但我想知道,我做的請求。

謝謝大家。

回答

1

你得到最後的請求與功能Zend_Http_Client->getLastRequest()。請注意,該函數返回一個字符串,您可能需要添加一些代碼才能將其放入有意義的JSON輸出中。以下添加到您的代碼:

$request = $client->getLastRequest() 
// make your changes to support JSON 
Log::notice("Request: " . $request) 

的功能也同時上線文檔在Introduction - Zend_Http - Zend Framework - Accessing Last Request and Response提及。

相關問題