Home  >  Article  >  php教程  >  php webservice 接口 实例 机票航班时刻表

php webservice 接口 实例 机票航班时刻表

WBOY
WBOYOriginal
2016-06-13 09:34:061006browse

<?php
header(&#39;Content-Type: text/html; charset=UTF-8&#39;);
$client = new SoapClient(&#39;http://webservice.webxml.com.cn/webservices/DomesticAirline.asmx?wsdl&#39;);	





$fromcity=!empty($_POST[&#39;fromcity&#39;]) ? trim($_POST[&#39;fromcity&#39;]) : &#39;长沙&#39;;
$tocity=!empty($_POST[&#39;tocity&#39;]) ? trim($_POST[&#39;tocity&#39;]) : &#39;广州&#39;;
$date=!empty($_POST[&#39;date&#39;]) ? trim($_POST[&#39;date&#39;]) : date(&#39;Y-m-d&#39;,time());



$parm=array(
&#39;startCity&#39;=>$fromcity,
&#39;lastCity&#39;=>$tocity,
&#39;theDate&#39;=>$date,
&#39;userID&#39;=>&#39;&#39;
);




$city=$client->getDomesticCity();
$city=get_object_vars($city);  
$city=$city[&#39;getDomesticCityResult&#39;]->any;

//print_r($city);
//var_dump($city);
$city_xml = simplexml_load_string($city); 





$result=$client->getDomesticAirlinesTime($parm);
$result=get_object_vars($result);  
$result=$result[&#39;getDomesticAirlinesTimeResult&#39;]->any;
//print_r($result[&#39;getDomesticAirlinesTimeResult&#39;]->any);


$obj_xml = simplexml_load_string($result);  
//print_r($obj_xml->children()->children());   
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>WecXml.com.cn 火车时刻表 Web Service 实例</title>
<style type="text/css">
<!--
@import url("css/c.css");
-->

</style>

</head>
<body>


  <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td>&#160;
                    
                </td>
            </tr>
            <tr>
                <td>
                    
                        </td>
            </tr>
            <tr>
                <td align="center">
                    <strong>WebXml.com.cn</strong><strong>
                         航班时刻表 Web Service 实例</strong></td>
            </tr>
            <tr>
                <td>&#160;
                    
                </td>
            </tr>
            <tr>
                <td>   
                </td>
            </tr>
            <tr>
                <td>&#160;
                    
                </td>
            </tr>
            <tr>
                <td>
                    <table width="100%" border="0" cellpadding="2" cellspacing="1" bordercolor="#FFFFFF"
                        bgcolor="#E5005A">
                        <tr>
                            <th  style="background-color: #FFD7E7;">
                                航空公司</th>
                            
                            <th style="width: 10%; background-color: #FFD7E7;">
                                航班编号</th>
                            <th style="width: 18%; background-color: #FFD7E7;">
                                出发机场</th>
                            <th style="width: 10%; background-color: #FFD7E7;">
                                出发时间</th>
                            <th style="width: 18%; background-color: #FFD7E7;">
                                到达机场</th>
                            <th style="width: 10%; background-color: #FFD7E7;">
                                到达时间</th>
                            <th style="width: 10%; background-color: #FFD7E7;">
                                机型</th>
                            <th style="width: 10%; background-color: #FFD7E7;">
                                中途是否停</th>
                        </tr>
                        
                             
                            <?php 
							
			foreach($obj_xml->children()->children() as $child)     
            {
               
			 ?>
             
         
                  
                                <tr>
                                    <td class="tdbg">
                                     <?php    echo $child->Company; ?>
                                     </td>
                                 
                                    <td class="tdbg" >
                                         <?php   echo $child->AirlineCode; ?>
                                    </td>
                                    <td class="tdbg" >
                                         <?php   echo $child->StartDrome; ?>
                                    </td>
                                    <td class="tdbg">
                                        <?php   echo $child->StartTime; ?>
                                    </td>
                                    <td class="tdbg">
                                        <?php   echo $child->ArriveDrome; ?>
                                    </td>
                                    <td class="tdbg">
                                       <?php   echo $child->ArriveTime; ?>
                                    </td>
                                    <td class="tdbg">
                                        <?php   echo $child->Mode; ?>
                                    </td>
                                    <td class="tdbg">
                                       <?php if($child->AirlineStop==0)  echo &#39;不停&#39;;else{echo &#39;停&#39;;} ?>
                                    </td>
                                </tr>
                           
                            <?php  }?>
                    </table>
                </td>
            </tr>
      
        </table>

</body>
</html>

Statement:
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
Previous article:PHP实现链表Next article:php substr,iconv_substr,mb_substr