Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pull banner performance from sailthru
<table>
<?php
require_once __DIR__ . '/inc/sailthru.php';
//Load sailthru client
global $sailthruSettings;
$sailthru = new Sailthru_Client($sailthruSettings['key'], $sailthruSettings['secret']);
$start = '2017-12-31';
$end = '2018-01-01';
for ($i = 0; $i < 31; $i++) {
echo '<th>' . $start .'</th>';
$resp = $sailthru->stats_blast(null, $start, $end, array('banners' => 1));
$keys = '';
$values = '';
$keys2 = '';
$values2 = '';
$blacklist = array('zone_id','banner_id','del','package_id');
// print_r($resp['banners']);
foreach ($resp['banners'][0] as $key => $val) {
if (!in_array($key,$blacklist)) {
$keys .= '<td>' . $key . '</td>';
$values .= '<td>' . $val . '</td>';
}
}
foreach ($resp['banners'][1] as $key => $val) {
if (!in_array($key,$blacklist)) {
$keys2 .= '<td>' . $key . '</td>';
$values2 .= '<td>' . $val . '</td>';
}
}
// echo '<td>Ad 1 (logo)</td>';
echo '<tr><td>Ad 1 (logo)</td>' . $keys . '</tr><tr><td>&nbsp;</td>' . $values . '</tr>';
// echo '<tr><td>Ad 2 (banner)</td></tr>';
echo '<tr><td>Ad 2 (banner)</td>' . $keys2 . '</tr><tr><td>&nbsp;</td>' . $values2 . '</tr>';
// echo '<pre>';
// print_r($resp);
// echo '</pre>';
$start = date('Y-m-d', strtotime($start . '+ 1 day'));
$end = date('Y-m-d', strtotime($end . '+ 1 day'));
}
?>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment