johnsmith153 Posted May 18, 2012 Share Posted May 18, 2012 An automated API is sending an XML message to a PHP file on my site. How do I deal with this? Quote Link to comment https://forums.phpfreaks.com/topic/262732-receive-xml-in-php/ Share on other sites More sharing options...
scootstah Posted May 18, 2012 Share Posted May 18, 2012 How is the PHP accepting it? What are you doing with it? Quote Link to comment https://forums.phpfreaks.com/topic/262732-receive-xml-in-php/#findComment-1346579 Share on other sites More sharing options...
johnny86 Posted May 18, 2012 Share Posted May 18, 2012 Seems like you know the exact entry point of the request since you are talking about a file on your server. Get the XML content from the request (presumably you just need the request body or some post parameter which holds the content) Load it with SimpleXMLElement http://www.php.net/SimpleXMLElement Exctract the data you need with xpath and create some kind of logic on what you will do with each request. On the other hand, if you're receiving soap requests, you could get to know to PHPs' own SoapServer http://www.php.net/SoapServer or use some wrapper library to handle the requests. For that you basically just need to create a service class which will hold all the actions provided by your API. Quote Link to comment https://forums.phpfreaks.com/topic/262732-receive-xml-in-php/#findComment-1346583 Share on other sites More sharing options...
johnsmith153 Posted May 18, 2012 Author Share Posted May 18, 2012 Does someone have a quick script that will receive this xml that is pated and convert to a string. I can then have the script email it so I can see what is happening. I am chatting with someone who is finishing in 5 minutes. I can spend the evening learning everything. Quote Link to comment https://forums.phpfreaks.com/topic/262732-receive-xml-in-php/#findComment-1346587 Share on other sites More sharing options...
johnsmith153 Posted May 18, 2012 Author Share Posted May 18, 2012 $xml = file_get_contents('php://input'); Quote Link to comment https://forums.phpfreaks.com/topic/262732-receive-xml-in-php/#findComment-1346595 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.