diff --git a/core/Client.php b/core/Client.php index 4e80038..1cd4181 100644 --- a/core/Client.php +++ b/core/Client.php @@ -124,6 +124,12 @@ protected function array2xml($arr, &$xml) final class Client extends iClient { + + /** + * Store the last response body string + */ + protected $lastResponseBody = null; + public function __construct($login, $password, $options = []) { if (empty($login) || empty($password)) @@ -270,6 +276,7 @@ public function raw_file_put($url, $content, $headers = []) */ public function request($method, $url, $options = [], $parse = true) { + $this->lastResponseBody = null; try { $response = $this->client->request($method, ltrim($url, '/'), $options); @@ -285,6 +292,14 @@ public function request($method, $url, $options = [], $parse = true) } } + /** + * Returns the XML string received in the last response. + * @return string $lastResponseBody + */ + public function getLastResponseBody() { + return $this->lastResponseBody; + } + /** * Prepare XML string body * @@ -335,6 +350,7 @@ private function parseResponse($response) } $responseBody = (string) $response->getBody(); + $this->lastResponseBody = $responseBody; if (!$responseBody) {