Skip to content

Instantly share code, notes, and snippets.

@calibr
Last active September 22, 2017 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calibr/000625b3e46cf5650d4f to your computer and use it in GitHub Desktop.
Save calibr/000625b3e46cf5650d4f to your computer and use it in GitHub Desktop.
<?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
Copy link

nasveli commented Sep 22, 2017

Good

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