Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.*",
Expand All @@ -36,4 +37,4 @@
"ZayconWhatCounts\\": "src/"
}
}
}
}
28 changes: 28 additions & 0 deletions src/ZayconWhatCounts/WhatCounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<data>", 0, 6, 1) == 0) return new \SimpleXMLElement($body);
if ((int)substr_compare($body, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>", 0, 38, 1) == 0) return new \SimpleXMLElement($body);
Expand Down Expand Up @@ -564,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
*
Expand Down