i receive this from rohini in my private message
i post here so that everybody can ... em... think!
actually, i really blur about what goal you really wish to attain.
To tell you frankly, XML file is easy to create, especially when you use the WDDX function to perform it.
// eg. for your code, you just need to use array variable.
$data = array(
'cnxserver' => 'http://217.20.40.68......',
'MSISDN' => $_POST['phone'],
);
$gotToSendData = wddx_serialize_vars( $data );
// you may write the $gotToSendData to a file if you want...
you can refer from here, anyway, i encourage you to download the manual... http://www.php.net/manual/en/function.wddx-serialize-vars.php
it is better to use the If -> Else in your statement.
To make your code clear. consider this.
$in = "POST HTTP/1.1\r\n".
"HOST: ".$CNXserverip."\r\n".
$xmlFile;
xml data posting
Hi .. thanks for your guidance but I already have the xml file so i dont want to re-create it. Below is my php file but i dont know whats wrong:
<?php
reset($HTTP_POST_VARS);
$mobile = $HTTP_POST_VARS["phone"];
$CNXserverip="http://217.20.40.68:8080/magapi/triggerApp.jsp";
$xmlFile ="<?xml version='1.0' ?><wddxPacket version='0.9'><header/><data><struct><var name='MSISDN'><string>".$mobile."</string></var></struct></data></wddxPacket>";
$socket = fsockopen($CNXserverip,8080, $errno, $errstr, 30);
if (!$socket)
{
echo "Error in the conection : $errstr($errno)<br>\n";
exit(-1);
}
$in = "POST HTTP/1.1\r\n";
$in .= "HOST: " .$CNXserverip."\r\n";
$in .= $xmlFile;
// echo
echo "Sending HTTP POST request...\n<br>***\n<br>".$in."***\n<br>";
fputs($socket, $in);
echo "\nResponse...\<br>***\n<br>";
sleep(2);
while ($socket && !feof($socket))
{
echo fgets($socket,4096);
}
fclose($socket);
?>