当前位置: 移动技术网 > IT编程>开发语言>PHP > php获取通过http协议post提交过来xml数据及解析xml

php获取通过http协议post提交过来xml数据及解析xml

2019年05月26日  | 移动技术网IT编程  | 我要评论
php 如何获取请求的xml数据,对方通过http协议post提交过来xml数据,php如何获取到这些数据呢?
复制代码 代码如下:

<?php
$xml_data ='<aatavailreq1>'.
'<agency>'.
'<iata>1234567890</iata>'.
'<agent>lgsoftwares</agent>'.
'<password>mypassword</password>'.
'<brand>phpmind.com</brand>'.
'</agency>'.
'<passengers>'.
'<adult age="" id="1"></adult>'.
'<adult age="" id="2"></adult>'.
'</passengers>'.
'<hotelavailreq1>'.
'<destcode>jhm</destcode>'.
'<hotelcode>oggshe</hotelcode>'.
'<checkindate>101009</checkindate>'.
'<checkoutdate>101509</checkoutdate>'.
'<usefield>1</usefield>'.
'</hotelavailreq1>'.
'</aatavailreq1>';
$url = "https://www.yourwebserver.com/path/";
$ch = curl_init($url);
curl_setopt($ch, curlopt_mute, 1);
curl_setopt($ch, curlopt_ssl_verifyhost, 0);
curl_setopt($ch, curlopt_ssl_verifypeer, 0);
curl_setopt($ch, curlopt_post, 1);
curl_setopt($ch, curlopt_httpheader, array('content-type: text/xml'));
curl_setopt($ch, curlopt_postfields, "$xml_data");
curl_setopt($ch, curlopt_returntransfer, 1);
$output = curl_exec($ch);
curl_close($ch);
?>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网