Hi!
I have this wordpress plugin that creates and verifies new software licenses. It does this by sending an array of data to the server. I'm trying to write a piece of processing code that creates a license key. I can successfully send variables to my PHP script and I know they are received; I check this using an if statement in my PHP code that checks if the variable 'send' is received and sends the array of data I mentioned before:
Processing code:
import processing.net.*;
Client c;
String secret_key = "56fc633286bc72.62466890";
String action = "slm_create_new";
String f = "James";
String l = "Doe";
String email = "jdoe@yahoo.com";
void setup() {
size(200, 200);
background(50);
fill(200);
c = new Client(this, "www.roham.comxa.com", 21);
loadStrings("http://"+"roham.comxa.com/test.php/?key="+secret_key);
loadStrings("http://"+"roham.comxa.com/test.php/?action="+action);
loadStrings("http://"+"roham.comxa.com/test.php/?first="+f);
loadStrings("http://"+"roham.comxa.com/test.php/?last="+l);
loadStrings("http://"+"roham.comxa.com/test.php/?email="+email);
String[] b = loadStrings("http://"+"roham.comxa.com/test.php/?send=GO");
println(b);
}
void draw() {
if (c.available() > 0) {
String dataIn = c.readString();
println(dataIn);
}
}
PHP script:
<?
$postURL = "roham.comxa.com";
$data=array();
$data['secret_key']=isset($_GET['key'])?$_GET['key']:"";
$data['slm_action']=isset($_GET['action'])?$_GET['action']:"";
$data['first_name']=isset($_GET['first'])?$_GET['first']:"";
$data['last_name']=isset($_GET['last'])?$_GET['last']:"";
$data['email']=isset($_GET['email'])?$_GET['email']:"";
$PHPSubmit = isset($_GET['send'])?$_GET['send']:"";
if($PHPSubmit == "GO")
{
echo "Sending Command ";
$ch = curl_init ($postURL);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returnValue = curl_exec ($ch);
var_dump($returnValue);
echo $returnValue;
}
?>
So by logic, if the script enters the if statement, I should be able to successfully create a new license, but I only get "Sending Command" and "string(25631)" which means there was no reply and no license is created when I check the database. I understand that this may be a PHP issue but want to make sure that the processing code is correct. Please help if you know anything about this!
Thanks!