handling XML sent via http:
Posted: Sat Feb 25, 2012 12:48 pm
Hi,
I’m trying to write a PHP page that receives XML from a remote sever (triggered by a third party event such as a message being sent to the server.) Thus, I am not querying a server and processing a response, but rather waiting for a unsolicited (but not unwelcome) call to my page.
If I have the XML in a local file, I can process the XML just fine with:
$url = 'xml-file.xml';
$xml = simplexml_load_file($url);
Btw the xml in the file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<ALERTSERVICE>
<PHONENUMBER>1234567890</PHONENUMBER>
<KEYWORD>Traffic</KEYWORD>
<CONTENTS>Route 42</CONTENTS>
</ ALERTSERVICE >
Can anyone provide with the code substitution for when the same XML is contained in the HTTP, like this:
http://www.some_server.com/process_test/process.php?xml=<?xml version="1.0" encoding="UTF-8"?><ALERTSERVICE><PHONENUMBER>1234567890</PHONENUMBER><KEYWORD>traffic</KEYWORD><CONTENTS>Route 42</CONTENTS></ALERTSERVICE>
I have the feeling that I’m missing something totally obvious, but have been fruitlessly searching and experimenting, up against a deadline. Thanks in advance for your help!
I’m trying to write a PHP page that receives XML from a remote sever (triggered by a third party event such as a message being sent to the server.) Thus, I am not querying a server and processing a response, but rather waiting for a unsolicited (but not unwelcome) call to my page.
If I have the XML in a local file, I can process the XML just fine with:
$url = 'xml-file.xml';
$xml = simplexml_load_file($url);
Btw the xml in the file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<ALERTSERVICE>
<PHONENUMBER>1234567890</PHONENUMBER>
<KEYWORD>Traffic</KEYWORD>
<CONTENTS>Route 42</CONTENTS>
</ ALERTSERVICE >
Can anyone provide with the code substitution for when the same XML is contained in the HTTP, like this:
http://www.some_server.com/process_test/process.php?xml=<?xml version="1.0" encoding="UTF-8"?><ALERTSERVICE><PHONENUMBER>1234567890</PHONENUMBER><KEYWORD>traffic</KEYWORD><CONTENTS>Route 42</CONTENTS></ALERTSERVICE>
I have the feeling that I’m missing something totally obvious, but have been fruitlessly searching and experimenting, up against a deadline. Thanks in advance for your help!