我有一个测试脚本可以通过 http post 接收一个 xml 文件,当我在内部使用它时它似乎工作正常。当我将脚本移动到可以从外部访问的 Web 服务器时,似乎没有发生任何事情。有人有什么想法吗?
<?php
if ( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
$inp = fopen("php://input");
$outp = fopen("xmlfile" . date("YmdHis") . ".xml", "w");
while (!feof($inp)) {
$buffer = fread($inp, 8192);
fwrite($outp, $buffer);
}
fclose($inp);
fclose($outp);
echo "<html><head>test response</head><body>OK</body></html>";
}
?>
要发布我正在使用 curl 的 xml,不确定这是否是问题所在?而且我没有发送到安全连接(HTTPS):
function httpsPost($Url, $xml_data)
{
//Initialisation
$ch=curl_init();
//Set parameters
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_URL, $Url);
//Return a variable instead of posting it directly
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Activate the POST method
curl_setopt($ch, CURLOPT_POST, 1);
//Request
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
//execute the connexion
$result = curl_exec($ch);
//Close it
curl_close($ch);
return $result;
}