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

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





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



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




$city=$client->getDomesticCity();
$city=get_object_vars($city);  
$city=$city['getDomesticCityResult']->any;

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





$result=$client->getDomesticAirlinesTime($parm);
$result=get_object_vars($result);  
$result=$result['getDomesticAirlinesTimeResult']->any;
//print_r($result['getDomesticAirlinesTimeResult']->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> 
                    
                </td>
            </tr>
            <tr>
                <td>
                    <a href="http://www.webxml.com.cn/">
                        <img src="images/webxml_logo.gif" alt="WebXml Logo" width="250" height="50" border="0" /></a></td>
            </tr>
            <tr>
                <td align="center">
                    <a href="http://www.webxml.com.cn/" target="_blank"><strong>WebXml.com.cn</strong></a><strong>
                         航班时刻表 Web Service 实例</strong></td>
            </tr>
            <tr>
                <td> 
                    
                </td>
            </tr>
            <tr>
                <td>   <form name="form1" method="post" action="2.php" id="form1">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td style="width: 50%;">
                                出发城市<select name="fromcity" >
                            
                                                <?php 
							
			foreach($city_xml->children()->children() as $ct)     
            {
			
			echo '<option  ';
			if($ct->cnCityName==$fromcity) echo 'selected="selected"';
			
			 echo ' val='.$ct->cnCityName.'> '.$ct->cnCityName.' </option>';
			//echo $ct->enCityName;
			//echo $ct->cnCityName;
			//echo $ct->Abbreviation;
			
			   }
			 ?>
             
                                </select>
                              
                                   到达城市
                               <select name="tocity" >
                            
                                                <?php 
							
			foreach($city_xml->children()->children() as $ct)     
            {
			
			echo '<option  ';
			if($ct->cnCityName==$tocity) echo 'selected="selected"';
			
			 echo ' val='.$ct->cnCityName.'> '.$ct->cnCityName.' </option>';
			//echo $ct->enCityName;
			//echo $ct->cnCityName;
			//echo $ct->Abbreviation;
			
			   }
			 ?>
             
                                </select>
                                   
                              <label for="CheckBox1">切换城市</label>
                                   
                                </td>
                            <td valign="middle">
                                日期
                                <input name="date" value="<?php echo $date?>" type="text" maxlength="10" size="10" id="date" class="input1" />
                                   
                                <input type="submit" name="Button2" value="查询" id="Button2" class="input2" /></td>
                        </tr>
                    </table>    </form>
                </td>
            </tr>
            <tr>
                <td> 
                    
                </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 '不停';else{echo '停';} ?>
                                    </td>
                                </tr>
                           
                            <?php  }?>
                    </table>
                </td>
            </tr>
      
        </table>

</body>
</html>

php webservice 接口 实例 机票航班时刻表,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。