Skip to content

Instantly share code, notes, and snippets.

@stibiumz
Created October 12, 2014 14:29
Show Gist options
  • Save stibiumz/25f161fa96bbb93340e1 to your computer and use it in GitHub Desktop.
Save stibiumz/25f161fa96bbb93340e1 to your computer and use it in GitHub Desktop.
<?php
/**
* Ve a http://panel.adtual.com/offers/offers_api y solicita la clave para la API
* En la url que hay abajo pega tu clave entre apy_key= y &limt
* Configura los países de los que no quieras ver ofertas dentro de $stopCountries
* (los códigos de estos los puedes sacar de http://en.wikipedia.org/wiki/ISO_3166-1
* , son los Alpha-2)
* Por último ejecuta el archivo en un servidor con PHP o en tu ordenador si tienes PHP instalado
*/
header('Content-type: text/html; charset=utf-8');
$stopCountries = ['ES', 'CO', 'MX', 'BO', 'PE', 'PY', 'EC', 'DO', 'VE', 'AR', 'PA', 'CL', 'UY', 'CR', 'NI'];
$data = json_decode(file_get_contents(
'http://panel.adtual.com/offers/offers.json?api_key=&limit=1000000'
))->data->offers;
$buffer = '';
foreach ($data as $offer) {
$countries = (array) explode(', ', $offer->countries_short);
if (! empty (array_intersect($stopCountries, $countries))) continue;
$buffer .= sprintf(
'<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td><a href="http://panel.adtual.com/offers/view/%d" target="_blank">Open &rsaquo;</a></td>
</tr>',
$offer->name,
$offer->countries,
($offer->payout . ' ' . $offer->currency),
$offer->categories,
$offer->id
);
}
?>
<html><head><meta charset="utf8"><style type="text/css">*,:after,:before{box-sizing:border-box}body{font-family:sans-serif;color:#222;background-color:#eee;}table{max-width:1260px;margin:10px auto;border-collapse:collapse;}thead th {background: none repeat scroll 0 0 white; border: 1px solid #f9f9f9;color:black;text-align: center;}tr{background:#f9f9f9;margin-bottom:5px}tr:nth-child(even){background:#f3f3f3}td,th{text-align:left;padding:20px;font-weight:300}</style></head><body>
<table>
<thead>
<tr>
<th>Name</th>
<th>Countries</th>
<th>Payout</th>
<th>Categories</th>
<th>Link</th>
</tr>
</thead>
<tbody><?=$buffer?></tbody>
</table></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment