Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
// 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://mgcash.com/api/?a=get_offers&key=8d54bd0a783a1a4c&".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";
die;
}
foreach($offers as $offer) {
// append the subid to each offer link
print '<a href="'.$offer->link.$subid.'">'.htmlspecialchars($offer->title).'</a><br>';
}

nasveli commented Sep 22, 2017

Good

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