我有一个测试脚本,通过http post发送xml文件,当我在内部使用它时,它似乎可以正常工作。当我将脚本移动到可从外部访问的Web服务器时,似乎没有任何事情发生。任何任何想法?通过http接收xml文件post
<?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>";
}
?>
要发布的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;
}
嗨,是的,它确实需要设置allow_url_fopen =在 – thegunner 2010-08-11 10:54:58
@thegunner:请参阅我的更新。 – Sarfraz 2010-08-11 10:58:07
嗨,谢谢。我试过,似乎给任何错误。基本上,网络服务器上的脚本只是上面的代码+你的更新。不知道什么是概率! – thegunner 2010-08-11 11:43:37