<?php
echo '<pre>';
$url = '';
$username = '';
$token = '';
$errors = [];
setlocale(LC_TIME, 'nl_NL');
date_default_timezone_set('Europe/Amsterdam');
$listid = 7445;
$xml_data = '
<xmlrequest>
<username>' . $username . '</username>
<usertoken>' . $token . '</usertoken>
<requesttype>stats</requesttype>
<requestmethod>GetUnsubscribes</requestmethod>
<details>
<statids>all</statids>
<order_by>unsubscribetime</order_by>
<order_dir>DESC</order_dir>
<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);
var_dump($xmlObj); exit;
if ($xmlObj->status == 'FAILED') {
$errors[] = 'Er konden geen gegevens uit de database worden opgehaald.';
} elseif ($xmlObj->status == 'SUCCESS') {
$table = '
<table>
<tr>
<th>E-mailadres</th>
<th>Subscriber ID</th>
<th>Lijst ID</th>
<th>Bounce tijd</th>
<th>Uitschrijf IP</th>
</tr>
';
foreach ($xmlObj->data->item as $item) {
$table .= '
<tr>
<td>'.$item->emailaddress.'</td>
<td>'.$item->subscriberid.'</td>
<td>'.$item->listid.'</td>
<td>'.strftime('%e %B %Y, %k:%M', (int)$item->unsubscribetime).'</td>
<td>'.$item->unsubscribeip.'</td>
</tr>
';
}
$table .= '
</table>';
echo $table;
}
if ($errors) {
var_dump($errors);
}
echo '</pre>';
?>
Opmerkingen
0 opmerkingen
U moet u aanmelden om een opmerking te plaatsen.