php获取通过http协议post提交过来xml数据及解析xml
程序员文章站
2023-11-15 14:13:22
php 如何获取请求的xml数据,对方通过http协议post提交过来xml数据,php如何获取到这些数据呢?复制代码 代码如下:
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);
?>
复制代码 代码如下:
<?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);
?>
推荐阅读
-
php获取通过http协议post提交过来xml数据及解析xml
-
php获取通过http协议post提交过来xml数据及解析xml
-
php获取通过http协议post提交过来xml数据及解析xml_php技巧
-
php获取通过http协议post提交过来xml数据及解析xml_php技巧
-
php获取通过http协议post提交过来xml数据及解析xml_PHP教程
-
php获取通过http协议post过来的xml数据
-
PHP 以POST方式提交XML、获取XML,解析XML详解及实例_php实
-
PHP 以POST方式提交XML、获取XML,解析XML详解及实例_php实
-
php获取通过http协议post提交过来xml数据及解析xml_PHP教程
-
PHP 以POST方式提交XML、获取XML,解析XML详解及实例