当我使用标题时:
$url='http://test.com/pay?login=160&pass=Test@123&ttype=NBFundTransfer&prodid=NSE&amt=50&txncurr=INR&txnscamt=0&clientcode=TkFWSU4%3d&txnid='.$string.'&date='.$date.'&custacc=1234567890&udf1=ajeesh&udf2=test@ttr.com';
header ('Location :'.$url);
我得到这个XML:
<MMP>
<MERCHANT>
<RESPONSE>
<url>http://test.com/pay</url>
<param name="ttype">NBFundTransfer</param>
<param name="tempTxnId">267040</param>
<param name="token">
r2X%2BE87UUszWqAz1xyWLJBlRhLuq7%2B3NdKTuhOb%2BbVw%3D
</param>
<param name="txnStage">1</param>
</RESPONSE>
</MERCHANT>
</MMP>
作为回应。我想用curl
做同样的事情。所以我试过了:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
$auth = curl_exec($curl);
echo $auth
$url
就是上面的那个。
但是当我echo $auth
时,我得到的只是1
作为回复而我没有得到XML。为什么会这样呢?我在做什么有什么不对吗?
答案 0 :(得分:1)
您缺少选项CURLOPT_RETURNTRANSFER
,请尝试此操作
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); //this line
$auth = curl_exec($curl);
echo $auth;