From 1d7b6d6264546ae025ff74872144fb01c1c3e4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Lok=C5=A1=C3=ADk?= Date: Mon, 27 Feb 2017 11:42:41 +0100 Subject: [PATCH 1/2] zrusena funkcia isValidXmlString() --- src/SmartEmailing.php | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/SmartEmailing.php b/src/SmartEmailing.php index ac95be5..909e02a 100644 --- a/src/SmartEmailing.php +++ b/src/SmartEmailing.php @@ -293,10 +293,10 @@ protected function callSmartemailingApiWithCurl($data) { return $this->getErrorXml($e->getCode(), $e->getMessage()); } + $xml = simplexml_load_string($response); - if ($this->isValidXmlString($response)) { - return new \SimpleXMLElement($response); - + if ($xml) { + return $xml; } else { return $this->getErrorXml('500', 'Unknown Smartemailing API error.'); } @@ -319,25 +319,4 @@ public function getErrorXml($code, $message) { return $xml; } - - /** - * check if xml string is valid - * - * @param string $xmlString - * @return bool - */ - protected function isValidXmlString($xmlString) { - libxml_use_internal_errors(TRUE); - - $doc = simplexml_load_string($xmlString); - - if (!$doc) { - $errors = libxml_get_errors(); - - return empty($errors); - } - - return FALSE; - } - } From c3fc8f284f8052f660624f378fb153aab018d82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Lok=C5=A1=C3=ADk?= Date: Mon, 27 Feb 2017 12:46:08 +0100 Subject: [PATCH 2/2] upravena podmienka --- src/SmartEmailing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SmartEmailing.php b/src/SmartEmailing.php index 909e02a..add7a90 100644 --- a/src/SmartEmailing.php +++ b/src/SmartEmailing.php @@ -295,7 +295,7 @@ protected function callSmartemailingApiWithCurl($data) { $xml = simplexml_load_string($response); - if ($xml) { + if ($xml !== FALSE) { return $xml; } else { return $this->getErrorXml('500', 'Unknown Smartemailing API error.');