php n xml
Posted: Thu Dec 18, 2008 7:19 pm
At present, i'm using curl. I am able to send the xml query over, and get a response. but the response is not what i am expecting.
This is the code im using..
when i use a standalone program to submit the exact same xml string to the same url, using post, i get this reply.
but when i use the above code, i get this instead..
is there something wrong with the way i'm executing the code? 
This is the code im using..
Code: Select all
$url = "http://xxx";
$xml = '<?xml version ="1.0" encoding="UTF-8"?>
<root>
<header>
<protocol>1</protocol>
<oem>xx</oem>
<agentID>xxx</agentID>
<password>xxxx</password>
</header>
<body>
<opCode>XX_AREAS_XX</opCode>
<item name=”ANTALYA” ID=”5” />
<item name=”JERUSALEM” ID=”1” />
</body>
</root>
';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'xml=' . $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch); #this returns html
Code: Select all
<body><version>3.91</version><opCode>OP_AREAS_LIST</opCode><country ID="27"><item name="Aachen, Germany" ID="13547" coreID="0"/><item name="Augsburg, Germany" ID="4408" coreID="0"/><item name="Bad Homburg, Germany" ID="5867" coreID="0"/><item name="Baden-Baden, Germany" ID="229" coreID="0"/><item name="Bautzen, Germany" ID="5889" coreID="0"/></country></body>
Code: Select all
<body><version>3.91</version><opCode>OP_OK</opCode></body>