Home > Backend Development > PHP Tutorial > 求PHP 上什么控件或函数可以发起XML请求和获取回数据解决办法

求PHP 上什么控件或函数可以发起XML请求和获取回数据解决办法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:09:31
Original
957 people have browsed it

求PHP 上什么控件或函数可以发起XML请求和获取回数据
现在要用PHP做一个航班查询,订购程序,联系了一下一家商旅平台,
他们技术提供的文档是一个提交表单,提交到他们服务端后,返回一个XML数据,要我用PHP的控件或函数可以发起XML请求和获取回数据

听的是头雾水,求方法,谢谢。最好能有一些案例。

------解决方案--------------------

PHP code
<?php $xml = '<xml>xmldata';//要发送的xml$url = 'http://localhost/test/getXML.php';//接收XML地址$header = 'Content-type: text/xml';//定义content-type为xml$ch = curl_init(); //初始化curlcurl_setopt($ch, CURLOPT_URL, $url);//设置链接curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//设置是否返回信息curl_setopt($ch, CURLOPT_HTTPHEADER, $header);//设置HTTP头curl_setopt($ch, CURLOPT_POST, 1);//设置为POST方式curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);//POST数据$response = curl_exec($ch);//接收返回信息if(curl_errno($ch)){//出错则显示错误信息    print curl_error($ch);}curl_close($ch); //关闭curl链接echo $response;//显示返回信息?><br><font color="#e78608">------解决方案--------------------</font><br>像楼上的 curl 或者 snoopy 或者 fopen 或者 fsockopen...<br><br>可以取得xml<br><br>解析 xml 用<br>SimpleXML 吧<br><br>先去翻阅这些东西的用法,然后就可以开工了,很简单的东西<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
curl simulated login
From 1970-01-01 08:00:00
0
0
0
Convert cURL command line to PHP cURL code
From 1970-01-01 08:00:00
0
0
0
Convert command line cURL to PHP cURL
From 1970-01-01 08:00:00
0
0
0
How to set boolean value true in php curl
From 1970-01-01 08:00:00
0
0
0
Please tell me, php curl request page shows blank
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template