The following data in the $res verbal is output from cURL and I am trying to use it to make the following script to work. But it does not processes the data at all. I have checked it an $lines[0] has SUCCESS in it as the first line. It should output the rest of the data but it doesn't.Any body have any ideas on how ti fix this. Or is it because I am not processing the data through cURL to test this. I what to make the script work perfect before I make it live. cURL pules the data from PayPal as pdt and PayPals sandbox is crap
$res = "SUCCESS
transaction_subject=Subscribe+to+Notary+Accounting
payment_date=16%3A29%3A09+May+24%2C+2014+PDT
txn_type=subscr_payment
subscr_id=S-01T86772CP0815034
last_name=Kurth
option_selection1=1+month
residence_country=US
item_name=Subscribe+to+Notary+Accounting
payment_gross=0.05
mc_currency=USD
business=rdkurth%40live.com
payment_type=instant
protection_eligibility=Ineligible
payer_status=unverified
payer_email=rich%40notaryaccounting.com
txn_id=94V17846W2603332N
receiver_email=rdkurth%40live.com
first_name=Richard
option_name1=Payment+options
payer_id=AAAE8FMAK2TH2
receiver_id=5GZ34FDY49A64
recur_times=4146841749
payment_status=Completed
payment_fee=0.05
mc_fee=0.05
btn_id=81809415
mc_gross=0.05
charset=windows-1252";
if(!$res){
//HTTP ERROR
}else{
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];
echo ("<p><h3>Thank you for your purchase!</h3></p>");
echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
echo ("");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
echo(' log for manual investigation');
}
}