<?php
echo '<pre>';
// CONFIG
$url = '';
$username = '';
$token = '';
$perpage = 200; // or 'all'
// /CONFIG
$errors = [];
$xml_data = '
<xmlrequest>
<username>' . $username . '</username>
<usertoken>' . $token . '</usertoken>
<requesttype>lists</requesttype>
<requestmethod>GetLists</requestmethod>
<details>
<start>0</start>
<perpage>all</perpage>
</details>
</xmlrequest>
';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_POST, true);
if (!ini_get('safe_mode') && ini_get('open_basedir') == '') {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'xml=' . $xml_data);
$pageData = curl_exec($ch);
if (!$pageData) {
$errors[] = curl_error($ch);
}
curl_close($ch);
$xmlObj = new SimpleXMLElement($pageData);
if ($xmlObj->status == 'FAILED') {
$errors[] = 'Er konden geen gegevens uit de database worden opgehaald.';
} elseif ($xmlObj->status == 'SUCCESS') {
$listids = array();
foreach ($xmlObj->data->item as $item) {
$listids[] = $item->listid;
}
$xml_data = '
<xmlrequest>
<username>' . $username . '</username>
<usertoken>' . $token . '</usertoken>
<requesttype>stats</requesttype>
<requestmethod>GetNewsletterStats</requestmethod>
<details>
<listids>'.implode(',', $listids).'</listids>
<sortinfo>
<SortBy>Date</SortBy>
<Direction>Down</Direction>
</sortinfo>
<newsletterid></newsletterid>
<start>0</start>
<perpage>'.$perpage.'</perpage>
</details>
</xmlrequest>
';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_POST, true);
if (!ini_get('safe_mode') && ini_get('open_basedir') == '') {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'xml=' . $xml_data);
$pageData = curl_exec($ch);
if (!$pageData) {
$errors[] = curl_error($ch);
}
curl_close($ch);
$xmlObj = new SimpleXMLElement($pageData);
if ($xmlObj->status == 'FAILED') {
$errors[] = 'Er konden geen gegevens uit de database worden opgehaald.';
} elseif ($xmlObj->status == 'SUCCESS') {
$table = '
<table>
<tr>
<th>ID</th>
<th>Verzendtijd</th>
<th>Ontvangers</th>
<th>Hardbounce</th>
<th>Softbounce</th>
<th>Overige bounces</th>
<th>Uitschrijvers</th>
<th>Opens / Unieke opens</th>
<th>Kliks</th>
<th>Nieuwsbrief</th>
<th>Mailinglijst</th>
<th>Lijst ID\'s</th>
</tr>
';
foreach ($xmlObj->data->item as $item) {
$table .= '
<tr>
<td>'.$item->statid.'</td>
<td>'.date('Y-m-d H:i:s', (int)$item->starttime).' - '.date('Y-m-d H:i:s', (int)$item->finishtime).'</td>
<td>'.$item->sendsize.'</td>
<td>'.$item->bouncecount_soft.'</td>
<td>'.$item->bouncecount_hard.'</td>
<td>'.$item->bouncecount_unknown.'</td>
<td>'.$item->unsubscribecount.'</td>
<td>'.$item->emailopens.' / '.$item->emailopens_unique.'</td>
<td>'.$item->linkclicks.'</td>
<td>'.$item->newslettername.'</td>
<td>'.$item->listname.'</td>
<td>'.$item->listids.'</td>
</tr>
';
}
$table .= '
</table>';
echo $table;
}
}
if (!empty($errors)) {
var_dump($errors);
}
echo '</pre>';
?>
Opmerkingen
0 opmerkingen
U moet u aanmelden om een opmerking te plaatsen.