简单试用航班查询接口

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Net;
using System.IO;
using System.IO.Compression;
using System.Text.RegularExpressions;
using System.Web.Script.Serialization;
namespace weizhang
{
class Program
{
static void Main(string[] args)
{

string name=”CA5901″;
string key = “**********************”;//申请的key值
string url = “http://apis.haoservice.com/plan/s?name=”+name+”&key=”+ key;
WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
string str = wc.DownloadString(url);
Console.WriteLine(str);
Console.ReadKey();

}
}
}

URL:http://apis.haoservice.com/plan/s
支持格式:json
http请求方式:GET POST
DEMO:http://apis.haoservice.com/plan/s?name=CA5901&key=yourkey
返回示例:
{
“error_code”: 0,
“reason”: “成功”,
“result”: [
{
“name”: “HU7779”,//航班号
“complany”: “海南航空股份有限公司”,//航空公司
“AirModel”: “738”,//机型
“AirAge”: null,//机年
“start”: “北京”,//起飞城市
“end”: “三亚”,//降落城市
“DepCode”: “BeiJing”,//起飞城市拼音
“ArrCode”: “SanYa”,//降落城市拼音
“startAirport”: “首都机场”,//起飞机场
“endAirport”: “凤凰机场”,//降落机场
“status”: “到达”,//飞机实时状态
“DepTime”: “06:45”,//计划起飞时间
“ArrTime”: “10:40”,//计划到达时间
“Dexpected”: “06:45 “,//预计起飞时间
“Aexpected”: ” 10:40″,//预计到达时间
“Dactual”: “06:48 “,//实时起飞时间
“Aactual”: ” 10:20″,//实时到达时间
“food”: “有餐食   “,//有无餐食
“OnTimeRate”: null,//准点率
“FlyTime”: “3小时32分”,//飞行时间
“Distance”: “2710KM  “,//飞行距离
“AverageDelay”: null,//平均延时
“ScheduleDaysOfWeek”: “1,2,3,4,5,6,7”//班期(有该航班的星期数,用英文逗号分隔,如一周中有4天:1,2,5,7)
}
]
}

备注:
航班查询,要先有key值,然后将自己想要查询的航班等输入;
若出现错误,请查看该网页 http://www.haoservice.com/docs/4/query/上的代码表.

Tagged:

Comments are closed.