我正在尝试使用php curl将数据从php插入到计数器中,当我通过提供ip 127.0.0.1在本地计算机中运行代码时,我已经成功插入数据,但是当我尝试它时,实时curl是给我错误,如连接超时无法连接到主机。 我也试过端口转发。
Below is my xml:
<ENVELOPE>
<HEADER>
<TALLYREQUEST>Import Data</TALLYREQUEST>
</HEADER>
<BODY>
<IMPORTDATA>
<REQUESTDESC>
<REPORTNAME>Vouchers</REPORTNAME>
<STATICVARIABLES> </STATICVARIABLES>
</REQUESTDESC>
<REQUESTDATA>
<TALLYMESSAGE xmlns:UDF="TallyUDF">
<VOUCHER VCHTYPE="Sales" Action="Create">
<ISOPTIONAL>No</ISOPTIONAL>
<VOUCHERTYPENAME>Sales</VOUCHERTYPENAME>
<DATE>20130413</DATE>
<EFFECTIVEDATE>20130413</EFFECTIVEDATE>
<ISCANCELLED>No</ISCANCELLED>
<USETRACKINGNUMBER>No</USETRACKINGNUMBER>
<ISPOSTDATED>No</ISPOSTDATED>
<DIFFACTUALQTY>No</DIFFACTUALQTY>
<VOUCHERNUMBER>11</VOUCHERNUMBER>
<REFERENCE>IS/11/13-14</REFERENCE>
<PARTYLEDGERNAME>INFOSOL</PARTYLEDGERNAME>
<NARRATION>Booked By: KUNAL SINGH | Used By: SANTOSH PARAB</NARRATION>
<ASPAYSLIP>No</ASPAYSLIP>
<ALTERID>11</ALTERID>
<ALLLEDGERENTRIES.LIST>
<REMOVEZEROENTRIES>No</REMOVEZEROENTRIES>
<ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
<LEDGERFROMITEM>No</LEDGERFROMITEM>
<LEDGERNAME>INFOSOL</LEDGERNAME>
<AMOUNT>-2200.00</AMOUNT>
<BILLALLOCATIONS.LIST>
<NAME>IS/11/13-14</NAME>
<BILLTYPE>New Ref</BILLTYPE>
<BILLCREDITPERIOD>20130413</BILLCREDITPERIOD>
<AMOUNT>-2200.00</AMOUNT>
</BILLALLOCATIONS.LIST>
</ALLLEDGERENTRIES.LIST>
<ALLLEDGERENTRIES.LIST>
<REMOVEZEROENTRIES>No</REMOVEZEROENTRIES>
<ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE>
<LEDGERFROMITEM>No</LEDGERFROMITEM>
<LEDGERNAME>Rental Income</LEDGERNAME>
<AMOUNT>1000.00</AMOUNT>
<CATEGORYALLOCATIONS.LIST>
<CATEGORY>Primary Cost Category</CATEGORY>
<COSTCENTREALLOCATIONS.LIST>
<NAME>Rental Income</NAME>
<AMOUNT>1000.00</AMOUNT>
</COSTCENTREALLOCATIONS.LIST>
</CATEGORYALLOCATIONS.LIST>
</ALLLEDGERENTRIES.LIST>
<ALLLEDGERENTRIES.LIST>
<REMOVEZEROENTRIES>No</REMOVEZEROENTRIES>
<ISDEEMEDPOSITIVE>No</ISDEEMEDPOSITIVE>
<LEDGERFROMITEM>No</LEDGERFROMITEM>
<LEDGERNAME>Parking N Toll</LEDGERNAME>
<AMOUNT>1200.00</AMOUNT>
</ALLLEDGERENTRIES.LIST>
</VOUCHER>
</TALLYMESSAGE>
</REQUESTDATA>
</IMPORTDATA>
</BODY>
</ENVELOPE>
And here is my php:
$server = "http://".$_SERVER['REMOTE_ADDR'].":9000";
$headers = array( "Content-type: text/xml" ,"Content-length: ".strlen($strXML) ,"Connection: close" );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$server);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $strXML);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec($ch);
if(curl_errno($ch)){
echo curl_error($ch);
echo " $server something went wrong..... try later ";
if($_GET[counter]==$_GET[total])
echo 'done###';
}else{
curl_close($ch);
}