The RSS Lead Checker is a great way to integrate you own custom offer display system and also query our servers when your customers have completed a lead. (this way you dont have to configure postback and maintain databases of completed leads on your servers.) Below your will find a list of url request variables and their descriptions along with an example Javascript/jQuery/Ajax and PHP script showing you how to use this tool.
RSS Lead Checker URL Variables:
| Variable |
Description |
Examples |
Required |
| &user_id= |
This is your affiliate id and is required to process your offer feed.
|
2549038 |
*Required |
| &key= |
This is your unique access key and is required to process your offer feed.
|
dfc18a047ae9a7b5dbdb99f6bf82ebde |
*Required |
| &time= |
This is how far back you want to check for a lead in our system.
|
1day, 2days, alltime |
*Required |
| &check= |
This tells our system if you are looking for leads based on your customers IP Address, or a tracking_id
|
ip, tracking_id |
*Required |
| &value= |
This is where you will enter your customers ip address, or tracking_id to begin your search.
|
102.211.146.47 |
*Required |
| Variable |
Required |
| &user_id= |
*Required |
|
This is your affiliate id and is required to process your offer feed.
|
| 2549038 |
| &key= |
*Required |
|
This is your unique access key and is required to process your offer feed.
|
| dfc18a047ae9a7b5dbdb99f6bf82ebde |
| &time= |
*Required |
|
This is how far back you want to check for a lead in our system.
|
| 1day, 2days, alltime |
| &check= |
*Required |
|
This tells our system if you are looking for leads based on your customers IP Address, or a tracking_id
|
| ip, tracking_id |
| &value= |
*Required |
|
This is where you will enter your customers ip address, or tracking_id to begin your search.
|
| 102.211.146.47 |
Javascript Ajax Example: (Place inside <head>...</head> section.)
(This example script will start a timer event that keeps checking for leads based on an ip address. Ideally you would put onclick="start_lead_check();" on your offer button elements so that this timer started only after a user clicked on one of your offers.)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
var path_to_php_checker = 'http://YOURSITE.COM/ajax_check_lead.php'; //This is the path to your php lead checker script.
var lead_check_timer;
function start_lead_check(){
console.log("Starting lead check timer."); //not required but useful for debugging.
check_lead(); //lets have it run a check right away for testing purposes.
clearInterval(lead_check_timer); //lets make sure we dont start multiple timers by clearing the existing timer here.
lead_check_timer = setInterval("check_lead();", 30000); //set up new timer that runs every 30 seconds or 30,000 miliseconds (do not set lower then 20 seconds.)
}
function check_lead(){
console.log("Checking lead system now."); //not required but useful for debugging.
$.ajax({
type: "POST",
url: path_to_php_checker,
success: function(msg){
eval(msg); //lets execute the javascript that is returned from the php lead checker script. (if any)
},
error: function (xhr, ajaxOptions, thrownError) {
clearInterval(lead_check_timer);
if(thrownError==''){
thrownError = 'Please check your path_to_php_checker variable to ensure you entered the correct url.';
}
alert("Ajax Error: ("+path_to_php_checker+") ("+xhr.status+"): "+thrownError);
}
});
}
</script>
PHP Lead Checker Example (ajax_check_lead.php):
(This is an example script that resides on your server and handles the rss lead checking logic.)
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type');
$check_value = $_SERVER['REMOTE_ADDR']; //lets use the customers ip to check for leads with.
$feedurl = 'http://www.cpagrip.com/common/lead_check_rss.php?user_id=2549038&key=dfc18a047ae9a7b5dbdb99f6bf82ebde&time=1day&check=ip&value='.$check_value;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $feedurl);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xml_string = curl_exec($ch);
curl_close($ch);
if($xml = simplexml_load_string($xml_string, 'SimpleXMLElement', LIBXML_NOCDATA)) {
if($xml->lead_info->lead_found == 'true'){
//we found a lead for the customer, lets tell the ajax caller script to redirect them.
echo 'clearInterval(lead_check_timer);';
echo 'alert("Lead completed, you may proceed.");'; //display a message box.
echo 'top.location.href="http://www.google.com";'; //redirect them to google.com.
}else{
echo 'console.log("lead not found, rechecking..")'; //not required but useful for debugging.
}
}else{
echo 'alert("Sorry, an error occured in lead check system, please try again later or contact the site administrator.");';
echo 'clearInterval(lead_check_timer);';
}
?>