Bonjour,
Sur une application Android/iphone je n'arrive pas a trouver la bonne facon de faire un http Post sans recevoir des caracteres chinois en reponse.
sUrlRequete est une chaîne
sUrlRequete = "http://exemple.com/login.php"
sNomAgent est une chaîne = "Mozilla/5.0 (Linux; U; Android 2.3.3; fr-fr; GT-I9100 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
HTTPCréeFormulaire("FORM")
HTTPAjouteParamètre("FORM", "username", "moi")
HTTPAjouteParamètre("FORM", "password", "pass")
SI PAS HTTPEnvoieFormulaire("FORM", sUrlRequete, httpPost,sNomAgent) ALORS
LIB_status ="error"
SINON
sBufBres est une chaîne = HTTPDonneRésultat(httpRésultat)
LIB_status="ok"
SAI_reponse =sBufBres
FIN
J'ai testé avec sBufBres est une chaîne ANSI plus de caractere chinois mais reponse pas complete...
Sur mobile par contre ca semble marche sur android mais incomplet sur iphone
script php :
<?php
if( $_POST["username"] || $_POST["password"] ) {
echo "Welcome ". $_POST['username']. "<br />";
echo "You are ". $_POST['password']. " pwd.";
$today = date("Y-m-d H:i:s");
$req_post =$_POST['username'];
$req_ip = print_r($_SERVER['REMOTE_ADDR'], True);
$req_method = print_r($_SERVER['REQUEST_METHOD'], True);
$req_agent = print_r($_SERVER['HTTP_USER_AGENT'], True);
$req_hour = print_r($today, True);
$req_dump = print_r($_SERVER['REQUEST_URI'], True);
$fp = fopen('./log/post.log', 'a');
fwrite($fp, $req_hour);
fwrite($fp, " - ");
fwrite($fp, $req_ip);
fwrite($fp, " - ");
fwrite($fp, $req_method);
fwrite($fp, " - ");
fwrite($fp, $req_agent);
fwrite($fp, " - ");
fwrite($fp, $req_post);
fwrite($fp, " - ");
fwrite($fp, $req_dump."\n");
fclose($fp);
exit();
}
?>
<html>
<body>
<form action = "<?php $_PHP_SELF ?>" method = "POST">
Name: <input type = "text" name = "username" />
Age: <input type = "text" name = "password" />
<input type = "submit" />
</form>
</body>
</html>