Jump to content

xml n php


gingar

Recommended Posts

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..

 

$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

 

how come when i use a standalone program to submit the exact same xml string to the same url, using post, i get this reply.

 

<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>

 

but when i use the above code, i get this instead?

<body><version>3.91</version><opCode>OP_OK</opCode></body>

 

is there something wrong with the way i'm executing the code?

Link to comment
https://forums.phpfreaks.com/topic/137502-xml-n-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.