接口描述
通过输入航班号,航班起降机场三字码,查询日期进行查询。
请求说明
接口域名
api.hangxx.com
请求示例
HTTP 方法:GET/POST
请求URL:https://接口域名/restapi/airQuery/flightTimeDetail?authCode=鉴权码&flightNo=航班号&leavePortCode=起飞机场三字码&arrivePortCode=降落机场三字码&queryDate=查询日期
url请求参数说明如下:
请求参数
参数 | 是否必选 | 类型 | 说明 |
---|---|---|---|
authCode | 是 | string | 航讯讯应用鉴权码,个人中心 -> 应用管理 -> 新建应用 -> 获得应用鉴权码 |
flightNo | 是 | string | 航班号 |
leavePortCode | 是 | string | 起飞机场三字码 |
arrivePortCode | 是 | string | 降落机场三字码 |
queryDate | 是 | string | 查询日期,格式:yyyy-MM-dd,如:1999-01-01,往前只能查询当前时间前3天的航班信息 |
请求代码示例
提示一:使用示例代码前,请记得替换相应的参数值。
提示二:部分语言依赖的类或库,请在代码注释中查看下载地址。
#请先安装requests模块 url='https://接口域名/restapi/airQuery/flightTimeDetail?authCode= &flightNo=&leavePortCode=&arrivePortCode=&queryDate=' r=requests.get(url) print r.text
//请先导入httpclient相应的包 HttpClient httpclient = HttpClients.createDefault(); HttpGet get = new HttpGet("https://接口域名/restapi/airQuery/flightTimeDetail?authCode=&flightNo= &leavePortCode=&arrivePortCode=&queryDate="); HttpResponse response = httpclient.execute(get); System.out.println(EntityUtils.toString(response.getEntity()));
<?php $host = "https://接口域名"; $path = "/restapi/airQuery/flightTimeDetail?authCode=&flightNo=&leavePortCode= &arrivePortCode=&queryDate="; $method = "GET"; $url = $host . $path; $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false); if (1 == strpos("$".$host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys); echo curl_exec($curl); ?>
using System.IO; using System.Text; using System.Net; using System.Net.Security; using System.Security.Cryptography.X509Certificates; private const String host = "https://接口域名"; private const String path = "/restapi/airQuery/flightTimeDetail?authCode=&flightNo=&leavePortCode= &arrivePortCode=&queryDate="; private const String method = "POST"; static void Main(string[] args) { String querys = ""; String url = host + path; HttpWebRequest httpRequest = null; HttpWebResponse httpResponse = null; if (0 < querys.Length) { url = url + "?" + querys; } if (host.Contains("https://")) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback (CheckValidationResult); httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url)); } else { httpRequest = (HttpWebRequest)WebRequest.Create(url); } httpRequest.Method = method; try { httpResponse = (HttpWebResponse)httpRequest.GetResponse(); } catch (WebException ex) { httpResponse = (HttpWebResponse)ex.Response; } Console.WriteLine(httpResponse.StatusCode); Console.WriteLine(httpResponse.Method); Console.WriteLine(httpResponse.Headers); Stream st = httpResponse.GetResponseStream(); StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8")); Console.WriteLine(reader.ReadToEnd()); Console.WriteLine("\n"); } public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; }
返回说明
返回结果示例
{ "code": 200, "message": "查询成功", "flightInfo": { "arrivePort": "首都机场", //到达机场 "planArriveTime": "2010-03-24 17:15", //计划到达时间 "realArriveTime": "2010-03-24 16:51", //实际到达时间 "expectArriveTime": "2010-03-24 16:51",//预计到达时间 "airlineCompany": "中国国航", //航空公司 "arrivePortCode": "PEK", //到达机场三字码 "planLeaveTime": "2010-03-24 14:45", //计划起飞时间 "boardGate": "46", //登机口 "arriveCity": "北京", //到达城市 "carryAirlineName": null, //实际承运航空公司 "realLeaveTime": "2010-03-24 15:02", //实际起飞时间 "expectLeaveTime": "2010-03-24 15:02", //预计起飞时间 "luggageCarousel": "33", //行李转盘 "flightDistance": "1178km", //飞行距离 "carryFlightNo": null, //实际承运航班 "arriveBuilding": "T3", //到达航站楼 "flightNo": "CA1524", //航班号 "leaveBuilding": "T2", //起飞航站楼 "flightDuration": "2小时30分", //飞行时间 "stateInfo": [ //实际状态信息 { "title": "飞行里程", "content": "1178KM", "desc": null }, { "title": "飞行时间", "content": "1h49min", "desc": null } ], "leavePort": "虹桥机场", //起飞机场 "state": "航班到达", //状态 "checkinTable": "A08-A21", //值机柜台 "leavePortCode": "SHA", //起飞机场三字码 "leaveCity": "上海" //起飞城市 } }