Instantly share code, notes, and snippets.

What would you like to do?
// For targeting purposes you need to set the ip parameter
$userIp = $_SERVER['REMOTE_ADDR'];
// Also for better targeting you need to pass the user agent
$userAgent = $_SERVER['HTTP_USER_AGENT'];
// How many offers you want to display.
$countOffers = 5;
// if we want to track the completion we can pass subid to an offer URL
$subid = "tracking-param";
$url = "".http_build_query(array(
"ip" => $userIp,
"ua" => $userAgent,
"count" => $countOffers,
// tell to MgCash that we want to receive a JSON response
"format" => "json"
$res = file_get_contents($url);
$offers = json_decode($res);
if(!$offers) {
print "Error: $res";
foreach($offers as $offer) {
// append the subid to each offer link
print '<a href="'.$offer->link.$subid.'">'.htmlspecialchars($offer->title).'</a><br>';

This comment has been minimized.

nasveli commented Sep 22, 2017


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment