网上也有,自己也整理了下,也算是转载吧。
提交xml的php文件这样写:
$xml =<<<xml
<?xml version="2.0" encoding="utf-8"?>
<RECORD>
<NAME>testOne</NAME>
<CHANNELID>1</CHANNELID>
</RECORD>
xml;
$xml = trim($xml);
$url = URL::route('pull.xml');
$header[] = 'Content-type; text/xml'; #必须声明Content-type为xml
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true); #定义post提交
curl_setopt($ch, CURLOPT_HEADER, true); #定义是否显示header头信息
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); # HEADER信息
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); # false 不显示返回流 true显示返回信息
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); # post的数据
curl_exec($ch);
获取xml的php文件这样写:
$xml = file_get_contents("php://input"); // 获取post过来的xml数据
至于怎么处理xml数据的方法,这里就不过多写了