简体   繁体   中英

Receive http $_POST and feed into SimpleXML

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, ie $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!

您最有可能在寻找原始POST数据

$postdata = file_get_contents("php://input");

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

$foo = "";
foreach( $_POST as $val )
{
    $foo .= $val;
}

好吧,如果您正在使用post接收xml,那么为什么不使用xmlrpc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM