最近我升级了我的VPS服务器以增加内存和存储空间
升级后,我注意到我的付款API开始出错
Error: Illegal characters found in URL
我之前从未遇到的,我的API用于处理 付款已经运行多年,并且在我升级后的3月份停止了付款
这是我目前使用的代码
<?php
/* $myparams = array();
$myparams['subpdtid'] = #### ;
$myparams['submittedref'] = $_SESSION['genref'] ;
$myparams['submittedamt'] = $_SESSION['amt4hash'] ;
$myparams['rettxref'] = $_POST['txnref'] ;
$myparams['retpayRef'] = $_POST['payRef'] ;
$myparams['retretref'] = $_POST['retRef'] ;
$myparams['retcardnum'] = $_POST['cardNum'] ;
$myparams['retappramt'] = $_POST['apprAmt'] ;
$myparams['nhash'] = '########################################################################' ;
*/
$subpdtid = ####; // your product ID
$submittedref = $_POST['tnx_ref']; // unique ref I generated for the trans
$submittedamt = $_POST['amount'];
//$rettxref= $_POST['txnref']; // ref from isw
//$retpayRef=$_POST['payRef']; // pay ref from isw
//$retretref = $_POST['retRef']; // ret ref from isw
//$retcardnum = $_POST['cardNum']; // ret cardnum from isw
//$retappramt = $_POST['apprAmt']; // ret appr amt from isw
$nhash = "04F61D7F7EEE6C80E5D227CA6DAAEA878F46C47B67A9DC7A5A699AD2D13A6249187E85667709F0D978D6697E33817DC771FBA109110ADAD1C4E642D20D439BC2" ; // the mac key sent to you
$hashv = $subpdtid.$submittedref.$nhash; // concatenate the strings for hash again
$thash = hash('sha512',$hashv);
// $credentials = "mithun:mithun";
$parami = array(
"productid"=>$subpdtid,
"transactionreference"=>$submittedref,
"amount"=>$submittedamt
);
$ponmo = http_build_query($parami) . "\n";
//$url = "https://stageserv.interswitchng.com/test_paydirect/api/v1/gettransaction.xml?$ponmo";// xml
$url = "https://webpay.interswitchng.com/paydirect/api/v1/gettransaction.json?$ponmo"; // json
//note the variables appended to the url as get values for these parameters
$headers = array(
"GET /HTTP/1.1",
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1",
//"Content-type: multipart/form-data",
//"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language: en-us,en;q=0.5",
//"Accept-Encoding: gzip,deflate",
//"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Keep-Alive: 300",
"Connection: keep-alive",
//"Hash:$thash",
"Hash: $thash " );
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,120);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER ,false);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
$data = curl_exec($ch);
if (curl_errno($ch)) {
print "Error: " . curl_error($ch);
}
else {
// Show me the result
// $json = simplexml_load_string($data);
$json = json_decode($data, TRUE);
//var_dump($data);
curl_close($ch);
print_r($json);
//echo ($json['ResponseCode']);
//echo ($json['ResponseDescription']);
// loop through the array nicely for your UI
}?>
<?php session_start();
//if(isset($_POST['name'])){
//$amt1 = htmlspecialchars(mysql_real_escape_string($_POST['amount'])) * 100 ;
$desc = $json['ResponseDescription'];
$_SESSION['desc'] = $desc;
$rep = $json['ResponseCode'];
$_SESSION['rep'] = $rep;
$tref = $_POST['tnx_ref'];
$_SESSION['tref'] = $tref;
$amts = $_POST['amount'] /100;
$_SESSION['amount'] = $amts;
//}
?>
<?php echo ($json['ResponseCode']); ?>
<?php echo ($json ->ResponseDescription);?><div align ="center"><h2 style="color:#090" align="center"> <?php echo ($json['ResponseDescription'] ); ?> </h2><br /><img src="wait.gif" width="200" /><div align ="center"><form action="query.php" method="post" name="niid" id="niid"></form><br /></div>
<script type="text/javascript">
window.onload=function(){
window.setTimeout(function() { document.niid.submit(); }, 3000);
};
</script>
<?php } else {?>
<div align ="center"><h2 style="color:#F00" align="center"> Your Transaction Was Not Successfull<br />Reason: <?php echo ($json['ResponseDescription'] ); ?></h2><br /><img src="wait.gif" width="200" /></div>
任何人都可以开导我吗?
答案 0 :(得分:1)
这是因为您在字符串
之后附加了不需要的\n
将您的代码更改为
$ponmo = http_build_query($parami);
//$url = "https://stageserv.interswitchng.com/test_paydirect/api/v1/gettransaction.xml?$ponmo";// xml
$url = "https://webpay.interswitchng.com/paydirect/api/v1/gettransaction.json?$ponmo"; // json