From 0a08f2243f97e853d0bd3e51ef4af46e17fae5b7 Mon Sep 17 00:00:00 2001 From: Phillip Smith Date: Thu, 16 Jul 2020 12:40:36 -0700 Subject: [PATCH 1/3] Use tidy to clean malformed XML --- src/ZayconWhatCounts/WhatCounts.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ZayconWhatCounts/WhatCounts.php b/src/ZayconWhatCounts/WhatCounts.php index ab2b387..2892a16 100644 --- a/src/ZayconWhatCounts/WhatCounts.php +++ b/src/ZayconWhatCounts/WhatCounts.php @@ -192,6 +192,16 @@ public function call($command, $data = NULL, $format = 'xml') return $result; } + $tidy_config = array( + 'indent' => true, + 'input-xml' => true, + 'output-xml' => true, + 'wrap' => false); + + $tidy = new \tidy(); + $tidy->parseString($body, $tidy_config); + $tidy->cleanRepair(); + $body = $tidy; if ((int)substr_compare($body, "", 0, 6, 1) == 0) return new \SimpleXMLElement($body); if ((int)substr_compare($body, "", 0, 38, 1) == 0) return new \SimpleXMLElement($body); From 358e9d17cb527d5572473b0600409c11b31e2f12 Mon Sep 17 00:00:00 2001 From: Phillip Smith Date: Thu, 16 Jul 2020 12:40:55 -0700 Subject: [PATCH 2/3] Add showSubscriberXML function --- src/ZayconWhatCounts/WhatCounts.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ZayconWhatCounts/WhatCounts.php b/src/ZayconWhatCounts/WhatCounts.php index 2892a16..cd4c747 100644 --- a/src/ZayconWhatCounts/WhatCounts.php +++ b/src/ZayconWhatCounts/WhatCounts.php @@ -574,6 +574,24 @@ public function deleteSubscribers(Array $subscribers) return trim($xml[1]); } + /** + * @param $subscriber_id + * + * @return SimpleXMLElement + * @throws Exception + * + * API documentation: https://whatcounts.zendesk.com/hc/en-us/articles/203969659 + */ + public function showSubscriberXML($subscriber_id) + { + $form_data = array( + 'subscriber_id' => $subscriber_id + ); + $xml = $this->call('detail', $form_data); + $subscriber_data = $xml->subscriber; + return $subscriber_data; + } + /** * @param $subscriber_id * From 298ac967689f14e640878b860f0a9d0a319068bb Mon Sep 17 00:00:00 2001 From: Phillip Smith Date: Thu, 3 Sep 2020 11:59:12 -0700 Subject: [PATCH 3/3] Add Tidy to requirements --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c2e3638..df00214 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,8 @@ "require": { "php": ">=5.5.9", "parsecsv/php-parsecsv": "0.4.5", - "guzzlehttp/guzzle": "~6.0" + "guzzlehttp/guzzle": "~6.0", + "ext-tidy": "*" }, "require-dev": { "phpunit/phpunit": "4.8.*", @@ -36,4 +37,4 @@ "ZayconWhatCounts\\": "src/" } } -} \ No newline at end of file +}