Need help with PHP postback

Hurricane

Beta member
Messages
4
Location
Switzerland
Hi,

I have implemented offertoro on my website and everything works fine expect the postback from my site.

Information from OfferToro:

The following information will be sent to your postback url:

id = The ID of the conversion in our system
oid = The ID of the offer converted in our system
amount = The amount that your user should receive for this conversion nominated in your currency. For example if your currency name is Points and your Currency Equivalent field is 35 and the conversion worths $1, we will send "35" in this field to you.
currency_name = The currency name that you set in your App's page.
user_id = The id of your user, the one you placed in the iframe integration.
payout = The publisher's revenue for this conversion.
o_name = The name of the offer converted.
sig = A signature to be sure the postback is legit. The signature is composed like this md5(oid + "-" + user_id + "-" + YOUR APP's KEY). You can find yor App's key in the App's detail page.


Important:

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.

Every time I get a error:
The postback is 0 and now my question:

What do I have to write in my PHP file that the postback is 1 and the user get his coins?

Sorry for my bad english im from switzerland:)

Regards,
Hurricane
 
Hi,

Yes I deposited the postbackURL on OfferToro (OfferToro)

And the postbackURL calls a PHP script on my website which should give the user his coins but I dont know how to return 1

PHP script to reward the user:

Code:
<?php 
ini_set('session.save_path',realpath('../../session'));
session_start(); 

$con = mysql_connect("127.0.0.1", "USER", "PASSWORD") or die("Connection not possible"); 

mysql_select_db("DB") or die ("DB not found"); 

$id = $_GET["id"]; 
$old = $_GET["old"]; 
$amount = $_GET["amount"]; 
$currency_name = $_GET["currency_name"];
$user_id = $_GET["user_id"];
$payout = $_GET["payout"]; 
$o_name = $_GET["o_name"]; 
$sig = $_GET["sig"]; 

if(!isset($_SESSION['username'])) {
	echo '<script type="text/javascript" language="Javascript">  
	alert("Not Logged In")  
	</script> ';
}else{
	
		$result = mysql_query("SELECT coins FROM TABLE WHERE id LIKE '$user_id' LIMIT 1" );
		$row = mysql_fetch_object($result);
		$coins = $row->coins;
		$coins = $coins + $amount;
		
	mysql_query("UPDATE TABLE SET coins='$coins' WHERE id LIKE '$user_id' LIMIT 1");

}			
echo 1; //This don't work
?>
 
Hmm that seems like an odd way of doing things...

First, have you tried echo '1'; instead? Wrapping the 1 in quotes in the code won't output them in your browser.

Second, are you sure they're not expecting a "1" as the response code? An echo and a response code are two very different things.
 
Last edited:
Also a heads up...you should probably think about creating stored procedures on your DB for your MySQL queries, so you're not prone to SQL Injection.
 
Yeah I tried echo '1';

"We expect a "1" (without quotes) as a response"
I tried this aswell http_response_code(1); it's also not working
 
There are many other potential issues we won't be able to see here. Things like, does the postback URL match exactly what they expect? Is their server not responding properly (meaning out of your control)?

If you're sure your end of the service is working as expected then the best option would be to contact their dev support.
 
Back
Top Bottom