Notifications via Postback ?
Everytime a user completes a task, watch a video, or completes any other of the many actions that rewards them, we're going to send you a Postback.
A Postback is simply a GET request we're going to do to your App's Postback URL that you setup during App Creation process.
Please note the following fields (get parameters) will be sent to your Postback URL
- transaction_id: Its the unique transaction ID for this conversion.
- offer_id: The unique ID of this offer in our system.
- offer_name: The name of the offer in our system.
- amount: The amount IN YOUR CURRENCY that the your user should receive for this conversion.
- virtual_currency: The name of your virtual currency, just for your reference.
- userid: The string that you replaced YOUR_USER_ID with when integrating the offerwall in your app. It could any string, even the raw username, like Michael00986.
- signature: An MD5 string composed as follows: md5(transaction_id/offer_id/your_app_key). You can find your app key in your APP's Integrate section.
- payout: Your payout in USD.
- subid1: Your subid1.
- subid2: Your subid2.
- subid3: Your subid2.
Very Important: Our system expects a "1" (number one) without quotes as the sole response to our Postback request.
Sample PHP Postback Script
<?php
/*
* Postback Example - OfferDaddy.com
*
*/
$your_app_key = "your_app_key_find_it_in_Integrate_section_of_your_account";
// Your database credentials.
define("MYSQL_HOST", "localhost");
define("MYSQL_PORT", "3306");
define("MYSQL_DB", "your_db");
define("MYSQL_TABLE", "your_table");
define("MYSQL_USER", "username");
define("MYSQL_PASS", "password");
$mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
if ($mysqli->connect_errno)
{
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
// Get Postback variables, for a complete list of list of variables, please go to https://www.offerdaddy.com/docs Postback tab
$transaction_id = urldecode($_GET["transaction_id"]);
$offer_id = urldecode($_GET["offer_id"]);
$offer_name = urldecode($_GET["offer_name"]);
$amount = urldecode($_GET["amount"]); //This is what your user is paid in your virtual currency, for example 300 coins
$virtual_currency = urldecode($_GET["virtual_currency"]); // This is simply the name of the currency of your app
$userid = urldecode($_GET["userid"]); //
$signature = urldecode($_GET["signature"]);
$payout = urldecode($_GET["payout"]);
$subid1 = urldecode($_GET["subid1"]);
$subid2 = urldecode($_GET["subid2"]);
$subid3 = urldecode($_GET["subid3"]);
//Check the signature
$my_signature = md5($transaction_id."/".$offer_id."/".$your_app_key);
if($my_signature != trim($signature)){
//Signatures don't match
echo "0";
exit(0);
}
//Possible make some other checks like if userid is actually a user in your system...
//then simply award the coins to your user
$sql = "UPDATE ".MYSQL_TABLE." SET coins=coins+".$mysqli->real_escape_string($amount)." WHERE userid = ".$mysqli->real_escape_string($userid);
$result = $mysqli->query($sql);
if($result){
echo "1";
}else{
echo "0";
}
exit(0);
?>