Here is the two scripts I have
Script 1:
<?
include('config.php');
$json = $_POST['payload'];
$fine = var_dump($json);
$secret = "78f12668216b562a79d46b170dc59f695070e532";
$obj = json_decode($json, true);
$fp = fopen('data.txt', 'w');
fwrite($fp, $json);
fwrite($fp, $fine);
fclose($fp);
if(sha1($json . $secret) == $_POST['signature']) {
$conversion_id = md5(($obj['amount']));
echo "OK";
echo $conversion_id;
mysql_query("INSERT INTO completed (`id`,`uid`,`completedid`) VALUES ('','".$obj['uid']."','".$conversion_id."')");
} else {
}
?>
Script 2:
<?
$json = $_POST['payload'];
$secret = "78f12668216b562a79d46b170dc59f695070e532";
$obj = json_decode($json);
if(sha1($json+$secret) == $_POST['signature']) {
print "OK";
} else {
}
?>
The problem here is that it is returning all NULL values. I am not an expert with JSON so I have no idea what is going on here. I really have no way of testing it because the information is coming from an outside website sending information such as this:
{
payload: {
uid: "900af657a65e",
amount: 50,
adjusted_amount: 25
},
signature: "4dd0f5da77ecaf88628967bbd91d9506"
}
The site allows me to test the script, but because json_decode is providing NULL values it will not get through the signature block.
According to Google Chrome's Dev Tools the response it sends when I try to test the script from their server is {"error":"The start uri returned a non-200 response."} that is all of the information it gives me it does not state what is being sent, only received
Is there a way I can test it myself? Or is there a simple error in this script that I may have just looked over?
EDIT
I set up a file to write the information being passed and this is what is being sent by their server
{"job_id":1337,"job_title":"CrowdFlower test job","amount":30,"uid":"inspire","adjusted_amount":50}
at first there was slashes so I added stripslashes() to the $json variable and that obviously got rid of the slashes, but once it hits the json_decode() it does not pull the information is there something wrong with the information being passed?
var_dump($json)before using thestripslashesand add the output to your question?