你的位置:首页 > ASP.net教程

[ASP.net教程]使用BO API制作天气查看软件


先来看看效果吧

 

接口地址:http://service.boapi.net/Weather/Weather.ashx?appkey=你申请的appkey&city=城市名称

接口说明详细信息查看http://www.boapi.net/weather.htm

请求服务关键代码

 

JToken WheatherJson(string city){   WebClient wc = new WebClient();   string json = "";   try   {      wc.Encoding = System.Text.Encoding.UTF8;      json = wc.DownloadString("http://service.boapi.net/Weather/Weather.ashx?appkey=你的appkey&city=" + city);      return (JToken)JsonConvert.DeserializeObject(json);   }   catch{}}

返回的结果

 

 

{"c":"101010100","cn":"中国","pn":"北京","dn":"北京","unch":"北京","unen":"beijing","date":"2015/4/22 11:00:00","fw":[{"dph":"晴","dp":"d00.gif","nph":"多云","np":"n01.gif","dt":"27","nt":"14","dwd":"南风","nwd":"南风","dwp":"3-4级","nwp":"3-4级","ss":"05:27|18:59"},{"dph":"多云","dp":"d01.gif","nph":"晴","np":"n00.gif","dt":"29","nt":"11","dwd":"北风","nwd":"无持续风向","dwp":"3-4级","nwp":"微风","ss":"05:25|19:00"},{"dph":"晴","dp":"d00.gif","nph":"晴","np":"n00.gif","dt":"27","nt":"14","dwd":"无持续风向","nwd":"无持续风向","dwp":"微风","nwp":"微风","ss":"05:24|19:01"}]}

返回参数说明

 

 

c城市代码fi天气指数
cn国名cin中文指数名称
pn省份直辖市自治区名称ic指数级别
dn市区名称ad指数相关建议
unch城市中文名称  
unen城市英文名称  
date天气更新时间  
fw未来天气  
dph白天天气现象  
dp白天天气图标  
nph夜晚天气现象  
np夜晚天气图标  
dt白天气温  
nt夜晚气温  
dwd白天风向  
nwd夜晚风向  
dwp白天风力  
nwp夜晚风力  
ss日出日落时间

如果你想要获取更多的天气图标 到http://www.boapi.net/TechBlog.aspx?id=1001&blog=boapi 下载