首页 航班查询 航班查询示例代码 航班查询[PHP]

航班查询示例代码[PHP]

作者: 阅读数:2242 上传时间:2018-06-07

航班查询

<?php

require_once 'curl.func.php';

$appkey = 'your_appkey_here';//你的appkey
$city = 'TYN';  //出发城市
$endcity = 'RMQ'; //到达城市
$flightno =''; //航班号
$url = "https://api.jisuapi.com/flight/query?city=$city&endcity=$endcity&flightno=$flightno&appkey=$appkey";

$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);

if($jsonarr['status'] != 0)
{
    echo $jsonarr['msg'];
    exit();
}

$result = $jsonarr['result'];
echo $result['city'].' '.$result['endcity'].' '.$result['flightno'].'
'; foreach($result['list'] as $val) { echo $val['flightno'].' '.$val['realflightno'].' '.$val['departportcode'].' '.$val['arrivalportcode'].' '. $val['departterminal'].' '.$val['arrivalterminal'].' '.$val['departdate'].' '.$val['arrivaldate']. ' '. $val['departtime'].' '.$val['arrivaltime'].' '.$val['departdateadd'].' '.$val['arrivaldateadd']. ' '. $val['craft'].' '.$val['stopnum'].' '. $val['costtime'].' '.$val['punctualrate'].'
'; foreach($val['pricelist'] as $v) { echo $v['cabinname'].' '.$v['cabincode'].' '.$v['price'].' '.$v['discount'].'
'; } echo $val['minprice'].' '. $val['airporttax'].' '.$val['fueltax'].' '. $val['food'].' '.$val['isasr'].' '. $val['iseticket'].' '.$val['iscodeshare'].'
'; }