先来看看效果吧
接口地址:http://service.boapi.net/Weather/Weather.ashx?appkey=你申请的appkey&city=城市名称
接口说明详细信息查看http://www.boapi.net/weather.htm
请求服务关键代码
class="prettyprint lang-cs">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 下载