I'm new here so please be patient, This is my request code, I want to write another piece of code in another server that will be accepting it and returning an xml 7101 success code using php and curl. How do I write code in a receiving server. This is actually API that I will be using to exchange data between my system and another remote system stored in clouds I have managed to send request successfully but I have stuck at receiving their requests, I have spent an entire week on it please help me out on receiving the requests when they send them to me.
success code is
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gepgBillSubReqAck>
<TrxStsCode>7101</TrxStsCode>
</gepgBillSubReqAck>
the request code is this,
<?php
//Bill Request
$content ="<gepgBillSubReq>
<BillHdr>
<SpCode>SP103</SpCode>
<RtrRespFlg>true</RtrRespFlg>
</BillHdr>
<BillTrxInf>
<BillId>1812022009968</BillId>
<SubSpCode>1001</SubSpCode>
<SpSysId>TANESCO001</SpSysId>
<BillAmt>1180</BillAmt>
<MiscAmt>0</MiscAmt>
<BillExprDt>2017-12-31T23:59:59</BillExprDt>
<PyrId>5144AA5914</PyrId>
<PyrName>test</PyrName>
<BillDesc>Bill Number 5913</BillDesc>
<BillGenDt>2017-12-21T09:39:00</BillGenDt>
<BillGenBy>Bhstenkubo</BillGenBy>
<BillApprBy>Bhstenkubo</BillApprBy>
<PyrCellNum/>
<PyrEmail/>
<Ccy>TZS</Ccy>
<BillEqvAmt>1180</BillEqvAmt>
<RemFlag>false</RemFlag>
<BillPayOpt>1</BillPayOpt>
<BillItems>
<BillItem>
<BillItemRef>5144AA5914</BillItemRef>
<UseItemRefOnPay>N</UseItemRefOnPay>
<BillItemAmt>1180</BillItemAmt>
<BillItemEqvAmt>1180</BillItemEqvAmt>
<BillItemMiscAmt>0</BillItemMiscAmt>
<GfsCode>140316</GfsCode>
</BillItem>
</BillItems>
</BillTrxInf>
</gepgBillSubReq>";
$resultCurlPost = "";
$serverIp = "XXXXXXXXXXXXXXXX";
$uri = "/XXX/XXX/qrequest"; //this is for qrequest
echo "Message ready to GePG:"."\n".$content."\n";
$ch = curl_init($serverIp.$uri);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type:application/xml',
'Gepg-Com:default.sp.in',
'Gepg-Code:SP103',
'Content-Length:'.strlen($content))
);
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50);
//Capture returned content from GePG
$resultCurlPost = curl_exec($ch);
curl_close($ch);
//$resultCurlPost=$data;
if(!empty($resultCurlPost)){
echo "\n\n";
echo "Received Response\n";
echo $resultCurlPost;
echo "\n";
}
else
{
echo "No result Returned"."\n";
}
?>
Thanks, you guys for contributing I found a solution, I used file_get_contents("php://input"); on the receiving server and so far it is working fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.