我想使用下面的代码将PHP连接到tally。但是当移至生产环境时会显示超时错误。但是当我在本地计算机上的计价器中运行代码时成功插入了数据显示错误无法连接到xxx.xxx.x.xx端口9000:连接超时出现了问题.....稍后再试
<?php
/* This is PHP code to insert an entry in Tally. All required XML tags by Tally are taken here in a string and name for Ledger is taken by posted value from HTML form. */
$requestXML = '<?xml version="1.0"?>
<ENVELOPE>
<HEADER>
<TALLYREQUEST>Export Data</TALLYREQUEST>
</HEADER>
<BODY>
<EXPORTDATA>
<REQUESTDESC>
<STATICVARIABLES>
<!--To Fetch data in XML format-->
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
<!--To Fetch data in HTML format, change the SVEXPORTFORMAT Tag value as -->
<!--$$SysName:HTML-->
</STATICVARIABLES>
<REPORTNAME>Balance Sheet</REPORTNAME>
</REQUESTDESC>
</EXPORTDATA>
</BODY>
</ENVELOPE>';
/* Actual code for importing goes here */
$server = 'http://xxx.xxx.x.xxx:9000';
$headers = array( "Content-type: text/xml" ,"Content-length: ".strlen($requestXML) ,"Connection: close" );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $server);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100000);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
if(curl_errno($ch))
{
print curl_error($ch);
echo " something went wrong..... try later";
}
else
{
echo " request accepted";
print $data;
curl_close($ch);
}
?>
答案 0 :(得分:1)
您的生产服务器无法访问此IP /端口,这就是连接超时错误的原因。