I have a Login class that will parse an xml sent from an iOS, Android phone. I’m not very good at php and my question is, how do I make my php page wait for a post? or do I just use
$xml = $_POST['login.xml'];
....
//parse
....
echo $responsexml;
he also suggested
$xml=readfile("php://input");
to read the xml string. I’m much confused about this post business. Any help will be greatly apreaciated!
When XML string will be sent via HTTP POST request, e. g. in your case in “login.xml” parameter, so yes, you can get this content by this code:
If you do not know in which parameter data will be, you can iterate through array $_POST. But it is unusual. When you are developing an app, at first you should create API in PHP and then you have to give developers of iOS and Android apps some specification, in which format data should be transferred (or, worse, they will give you some specification of in which format they are sending data).
By the way. I think the simplest solution for this would be to send a POST request with data parameters “login” and “password”, for example. PHP would than run some verification and return some session id. And for all requests of this type, it’s better to avoid XML, all data can go via HTTP requests. And then you don’t have to parse anything: