OfferToro Postback Help
2016-12-30, 06:58 PM,
#1
Hi, I'm currently setting up an OfferToro offer wall and testing the postback on their website works perfectly fine, however when a user actually completes an offer it gets sent 5 times.

Their guide states:

"We expect a "1" (without quotes) as a response to a successfull received postback and a "0" (without quotes) to indicate that the postback was not received correctly. We will try to send the postback up to 5 times if not receiving a "1" as a reply. After that we will send you an email with the data of the conversion so you can process it manually."

So clearly I am not responding with a 1, as the postback is getting sent 5 times resulting in my offer wall rewarding 5x the points it should. I'm a bit of a newbie with php and so any help on how to respond with a 1 would be greatly appreciated.

I have contacted support but they were of no help whatsoever telling me just to figure it out myself.
Reply
2016-12-30, 11:48 PM,
#2
Well can you post the code?
Reply
2016-12-31, 06:54 PM,
#3
(2016-12-30, 11:48 PM)CegaFin Wrote: Well can you post the code?

Code:
<?php

session_start();

$servername = "localhost";
$dbusername = "";
$dbpassword = "";
$dbname = "";

// Create connection
$conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

mysqli_query($conn, "SET NAMES utf8");

include_once("../../functions.php");


        // get variables and prevent against SQL injections
$campaign_id = mysqli_real_escape_string($conn, $_GET['campaign_id']);            // Campaign ID
$campaign_name = mysqli_real_escape_string($conn, $_GET['campaign_name']);        // Campaign Name        
$subid = mysqli_real_escape_string($conn, $_GET['sid']);                         // Primary SubID
$subid2 = mysqli_real_escape_string($conn, $_GET['sid2']);                      // Secondary SubID2
$subid3 = mysqli_real_escape_string($conn, $_GET['sid3']);                      // Secondary SubID3
$commission = mysqli_real_escape_string($conn, $_GET['commission']);            // Commission        
$status = mysqli_real_escape_string($conn, $_GET['status']);                      // Status: 1 (Credited) or 2 (Reversed)
$ip = mysqli_real_escape_string($conn, $_GET['ip']);                              // User IP Address
$reversal_reason = mysqli_real_escape_string($conn, $_GET['reversal_reason']);  // Reversal Reason (usually not sent)
$vc_value = mysqli_real_escape_string($conn, $_GET['vc_value']);                  // Virtual Currency Only - VC Ratio * Commission    
$sig = mysqli_real_escape_string($conn, $_GET['sig']);                  // sig    

if ($sig == md5($campaign_id . "-" . $subid . "-" . "")) {

    
    
    
$query = mysqli_query($conn, "SELECT u.* FROM users u WHERE u.username='{$subid}'");
$u = mysqli_fetch_array($query, MYSQLI_ASSOC);
    
$text = $campaign_name;
$type = "Offer";
$provider = "Offer Toro";
mysqli_query($conn, "INSERT INTO `activity_history`(user_id, history_type, history_provider, history_text, history_points, history_date, history_fee) VALUES('{$u['user_id']}', '{$type}', '{$provider}', '{$text}', '{$vc_value}', NOW(), '0.00')");

mysqli_query($conn, "UPDATE `users` SET `points`=`points`+'".$vc_value."', `earnings`=`earnings`+'".$vc_value."' WHERE `user_id`='{$u['user_id']}'");
if ($u['referral']) {
    mysqli_query($conn, "UPDATE `users` SET `points`=`points`+'".($vc_value/10)."' WHERE `user_id`='{$u['referral']}'");
}

http_response_code(1);


}


?>

The http_response_code(1) is something I tried after it didn't work and I still have the same problem, even though the postback test is saying everything is fine. When I get a real lead it says it fails but the postback goes through 5 times.
Reply
2016-12-31, 11:09 PM,
(This post was last modified: 2016-12-31, 11:14 PM by CegaFin.)
#4
I dont see any errors in the code.
By what you are saying it seems that you are not receiving the correct status or maybe not even checking for it.

Maybe im not understanding how this code works.
Where is the part of the code where you check the status variable?

On receiving status do a print to check rather it is 1 or 0.
Reply
2017-01-01, 08:29 PM,
#5
(2016-12-31, 11:09 PM)CegaFin Wrote: I dont see any errors in the code.
By what you are saying it seems that you are not receiving the correct status or maybe not even checking for it.

Maybe im not understanding how this code works.
Where is the part of the code where you check the status variable?

On receiving status do a print to check rather it is 1 or 0.

The code runs fine as the postback goes through, it's just that I'm not responding with a 1 as they requested.

The status variable isn't actually used for this postback, I check that it is valid by using the sig variable (I have removed my 'secret key' from the code). So if the sig variable is correct then a 1 should be returned, however I'm not sure how to do that.

I know the rest of it is working as users get credited with points when they complete an offer, it just gets sent 5 times as I am not responding with a 1.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  [HELP] Need some PHP postback help! CEED 0 411 2014-03-07, 08:02 AM
Last Post: CEED
  Question about postback with CPAgrip Jaysamuel 2 774 2014-01-25, 09:40 PM
Last Post: Jaysamuel
  Postback help Jaysamuel 2 483 2013-12-26, 01:39 AM
Last Post: Jaysamuel




About Us | Contact Us | CPA Elites | Advertise | Stats | Staff Team

© 2013-2017 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top