J'ai un script de test pour recevoir un fichier xml via http post et il semble fonctionner correctement quand je l'utilise en interne. Lorsque je déplace le script vers un serveur Web auquel il est possible d'accéder à l'extérieur, rien ne semble se produire. Quelqu'un a des idées?recevoir le fichier xml via http 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>";
}
?>
Pour poster le fichier XML, j'utilise curl, je ne sais pas si c'est le problème? et je ne suis pas l'envoi d'une connexion sécurisée (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;
}
Salut, oui, ça fait plaisir d'être configuré allow_url_fopen = On – thegunner
@thegunner: Voir ma mise à jour s'il vous plaît. – Sarfraz
Salut, merci. J'ai essayé cela semble donner des erreurs. Fondamentalement, le script sur le serveur web est seulement ce code ci-dessus + votre mise à jour. Je ne sais pas quel est le problème! – thegunner