PHP获取POST方式的XML数据

今天做微信支付开发,微信服务器回调的时候,会发送XML数据到我的服务器,用以往的POST,GET是获取不到的

百度了一下,应该是

$file_in = file_get_contents("php://input"); //接收post数据
$xml = simplexml_load_string($file_in);//转换post数据为simplexml对象

$data = array();
foreach($xml->children() as $child){
  $data[$child->getName()] = $child->__toString();
}

原文地址:https://www.cnblogs.com/xiaozong/p/5228039.html