public function run()
{
$postFields = 'cmd=_notify-validate';
foreach($_POST as $key => $value)
{
$postFields .= "&$key=".urlencode($value);
}
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $this->_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postFields
));
$result = curl_exec($ch);
curl_close($ch);
$fh = fopen('result.txt', 'w');
fwrite($fh, $result . ' -- ' . $postFields);
fclose($fh);
echo $result;
}
}
?>
我在一个文本文件中得到结果,如下所示:
?cmd=_notify-validate&test_ipn=1&payment_type=instant&payment_date=02:39:41 Oct 06, 2011 PDT&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer@paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John Smith&address_country=United States&address_country_code=US&address_zip=95131&address_state= CA&address_city=San Jose&address_street=123, any street&business=seller@paypalsandbox.com&receiver_email=seller@paypalsandbox.com&receiver_id=TESTSELLERID1&residence_country=US&item_name=something&item_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=9.34&txn_type =web_accept&txn_id=41106939¬ify_version=2.1&custom=xyz123&charset=windows-1252&verify_sign=AB3bSjvFd3wXL7rCt.OOGW-nSKg-Ahh5RbboVG4bn9LSAon94Wjt2Oj9
如何解码此字符串并将其放入 mysql 数据库?
我需要将客户的名字、姓氏、地址、电子邮件、项目编号、项目名称、数量、运输和时间戳放入数据库。请我已经在代码中走了这么远,我只需要帮助解码它并将其输入数据库。谢谢