-
-
Save calibr/000625b3e46cf5650d4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good