1

I'm currently trying to setup a page which receives XML via an HTTP POST. I have successfully used SimpleXML to retrieve the XML from a file and then perform my logic, but I am unsure how to set it up to receive a POST submission.

Is there a default way to retrieve all information from $_POST as a string?

//'get'ting the xml from a file
$job = simplexml_load_file(/path/to/file);

//my assumption on how to accept the XML post - throws a not string error
$job = simplexml_load_string($_POST);

As the is being received from a third party, is there extra information that I am not being supplied? All my previous handlings have been with name=value pairs, i.e. $value = $_POST['name']; To rephrase, do all HTTP POSTs have a name handle to them?

Sorry for the multi-faceted question, I'm a bit lost, so am trying to cover all angles.

Any help is greatly appreciated!

tiltos
  • 144
  • 2
  • 12

3 Answers3

1

You're most likely looking for the raw POST data.

$postdata = file_get_contents("php://input");
sikander
  • 2,286
  • 16
  • 23
0

This code will combine all posted variables into a single string variable:

$foo = "";
foreach( $_POST as $val )
{
    $foo .= $val;
}
Mr Wednesday
  • 552
  • 4
  • 16
0

well, if you are receiving xml with using post, why not are you using xmlrpc?

sedat sevgili
  • 156
  • 1
  • 6