I have written a script that posts an XML request to my server. See below:
$xml_request='<?xml version="1.0"?><request><data></data></request>';
$url='http://www.myserver.com/xml_request.php';
//Initialize handle and set options
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_request);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));
$result = curl_exec($ch);
curl_close($ch);
Now I'm trying to figure out how to parse that request on the server side. If I do a simple
print_r($_POST);
it returns:
Array
(
[<?xml_version] => \"1.0\"?><request><data></data></request>
)
which doesn't seem right. I want to be able to pass the post into one of the XML parsers - most likely simplexml_load_string(), so I need access to the clean XML file. How do I access the POST request so I get a clean file?