根据城市查询天气状况
2014-09-23 15:16
239 查看
天气查询接口演示代码:
using System;
using System.Text;
using System.Net;
namespace tianqi
{
class Program
{
static void Main(string[] args)
{
string key = "*********************";//申请的key值
string cityname = "北京";//输入想要查询的城市名
string url = "http://apis.haoservice.com/weather?cityname=" +cityname + "&key=" + key;
WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
string str = wc.DownloadString(url);
Console.WriteLine(str);
Console.ReadKey();
}
}
}
天气查询接口返回示例代码:
天气查询接口:http://www.haoservice.com/docs/6
支持格式: json
http请求方式:GET POST
返回示例:
{
"resultcode": "200",
"reason": "查询成功!",
"result":{
"sk":{ /*当前实况天气*/
"temp": "21", /*当前温度*/
"wind_direction": "西风", /*当前风向*/
"wind_strength": "2级", /*当前风力*/
"humidity": "4%", /*当前湿度*/
"time": "14:25" /*更新时间*/
},
"today": {
"city": "天津",
"date_y": "2014年03月21日",
"week": "星期五",
"temperature": "8℃~20℃", /*今日温度*/
"weather": "晴转霾", /*今日天气*/
"weather_id": { /*天气唯一标识*/
"fa": "00", /*天气标识00:晴*/
"fb": "53" /*天气标识53:霾 如果fa不等于fb,说明是组合天气*/
},
"wind": "西南风微风",
"dressing_index": "较冷", /*穿衣指数*/
"dressing_advice": "建议着大衣、呢外套加毛衣、卫衣等服装。", /*穿衣建议*/
"uv_index": "中等", /*紫外线强度*/
"comfort_index": "",/*舒适度指数*/
"wash_index": "较适宜", /*洗车指数*/
"travel_index": "适宜", /*旅游指数*/
"exercise_index": "较适宜", /*晨练指数*/
"drying_index": ""/*干燥指数*/
},
"future": {
/*未来几天天气*/
"day_20140321": {
"temperature": "8℃~20℃",
"weather": "晴转霾",
"weather_id": {
"fa": "00",
"fb": "53"
},
"wind": "西南风微风",
"week": "星期五",
"date": "20140321"
},
"day_20140322": {
"temperature": "9℃~21℃",
"weather": "霾转多云",
"weather_id": {
"fa": "53",
"fb": "01"
},
"wind": "东北风微风转东南风微风",
"week": "星期六",
"date": "20140322"
},
.......
"day_20140327": {
"temperature": "11℃~20℃",
"weather": "阴转多云",
"weather_id": {
"fa": "02",
"fb": "01"
},
"wind": "南风微风转无持续风向微风",
"week": "星期四",
"date": "20140327"
}
}
}
}
using System;
using System.Text;
using System.Net;
namespace tianqi
{
class Program
{
static void Main(string[] args)
{
string key = "*********************";//申请的key值
string cityname = "北京";//输入想要查询的城市名
string url = "http://apis.haoservice.com/weather?cityname=" +cityname + "&key=" + key;
WebClient wc = new WebClient();
wc.Encoding = Encoding.UTF8;
string str = wc.DownloadString(url);
Console.WriteLine(str);
Console.ReadKey();
}
}
}
天气查询接口返回示例代码:
天气查询接口:http://www.haoservice.com/docs/6
支持格式: json
http请求方式:GET POST
返回示例:
{
"resultcode": "200",
"reason": "查询成功!",
"result":{
"sk":{ /*当前实况天气*/
"temp": "21", /*当前温度*/
"wind_direction": "西风", /*当前风向*/
"wind_strength": "2级", /*当前风力*/
"humidity": "4%", /*当前湿度*/
"time": "14:25" /*更新时间*/
},
"today": {
"city": "天津",
"date_y": "2014年03月21日",
"week": "星期五",
"temperature": "8℃~20℃", /*今日温度*/
"weather": "晴转霾", /*今日天气*/
"weather_id": { /*天气唯一标识*/
"fa": "00", /*天气标识00:晴*/
"fb": "53" /*天气标识53:霾 如果fa不等于fb,说明是组合天气*/
},
"wind": "西南风微风",
"dressing_index": "较冷", /*穿衣指数*/
"dressing_advice": "建议着大衣、呢外套加毛衣、卫衣等服装。", /*穿衣建议*/
"uv_index": "中等", /*紫外线强度*/
"comfort_index": "",/*舒适度指数*/
"wash_index": "较适宜", /*洗车指数*/
"travel_index": "适宜", /*旅游指数*/
"exercise_index": "较适宜", /*晨练指数*/
"drying_index": ""/*干燥指数*/
},
"future": {
/*未来几天天气*/
"day_20140321": {
"temperature": "8℃~20℃",
"weather": "晴转霾",
"weather_id": {
"fa": "00",
"fb": "53"
},
"wind": "西南风微风",
"week": "星期五",
"date": "20140321"
},
"day_20140322": {
"temperature": "9℃~21℃",
"weather": "霾转多云",
"weather_id": {
"fa": "53",
"fb": "01"
},
"wind": "东北风微风转东南风微风",
"week": "星期六",
"date": "20140322"
},
.......
"day_20140327": {
"temperature": "11℃~20℃",
"weather": "阴转多云",
"weather_id": {
"fa": "02",
"fb": "01"
},
"wind": "南风微风转无持续风向微风",
"week": "星期四",
"date": "20140327"
}
}
}
}
相关文章推荐
- 根据城市查询天气状况
- 根据城市名称查询天气状况
- 根据城市名查询天气状况
- 根据城市查询天气状况
- php根据地址的经纬度查询周围的城市例子
- ECharts的geojson地图数据下载(根据城市区划代码的前六位查询)
- Jquery如何序列化form表单数据为JSON对象 C# ADO.NET中设置Like模糊查询的参数 从客户端出现小于等于公式符号引发检测到有潜在危险的Request.Form 值 jquery调用iframe里面的方法 Js根据Ip地址自动判断是哪个城市 【我们一起写框架】MVVM的WPF框架(三)—数据控件 设计模式之简单工厂模式(C#语言描述)
- jquery这个webservice根据选择城市查询天气
- 【接口】根据经纬度查询具体城市信息
- 根据IP查询所在城市接口(查询用户所在城市)
- [推荐] 最新手机号段归属地数据库(2015年11月) 根据手机号 查询所在地 省份 城市 县城
- 根据地址的经纬度查询周围的城市
- 根据城市查询年天气状况
- 长途汽车站api 根据城市名查询汽车站相关信息
- 心知天气api,根据城市名/id查询天气
- 根据省份级联查询城市(WinForm)
- 根据城市查询天气
- 根据IP地址查询其所属城市
- 在SAE上开发LBS应用之 根据一点的经纬度实现附近点的查询
- MySQL 千万 级数据量根据(索引)优化 查询 速度