天气查询接口
根据城市名(IP)查询天气
演示示例代码:
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();
}
}
}
支持格式:json
http请求方式:GET POST
DEMO: http://apis.haoservice.com/weather?cityname=北京&key=您申请的KEY
参数说明:
名称 类型 是否必须 说明
Cityname(IP) string Y 城市名,如:"北京"
dtype string Y 返回数据格式:json
key string Y 你申请的key
返回示例:
{
"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": ""/*干燥指数*/
},
……
"day_20140326": {
"temperature": "10℃~19℃",
"weather": "多云",
"weather_id": {
"fa": "01",
"fb": "01"
},
"wind": "南风微风",
"week": "星期三",
"date": "20140326"
},
"day_20140327": {
"temperature": "11℃~20℃",
"weather": "阴转多云",
"weather_id": {
"fa": "02",
"fb": "01"
},
"wind": "南风微风转无持续风向微风",
"week": "星期四",
"date": "20140327"
}
}
}
}
天气种类及标识列表
支持格式:json
http请求方式:GET POST
DEMO: http://apis.haoservice.com/weather/uni?key=您申请的KEY
参数说明:
名称 类型 是否必须 说明
key string Y 你申请的key
返回示例:
{
"resultcode": "200",
"reason": "successed",
"result": [
{
"wid": "00",
"weather": "晴"
},
{
"wid": "01",
"weather": "多云"
},
{
"wid": "02",
"weather": "阴"
},
{
"wid": "03",
"weather": "阵雨"
},
{
"wid": "04",
"weather": "雷阵雨"
},
{
"wid": "05",
"weather": "雷阵雨伴有冰雹"
},
……
{
"wid": "30",
"weather": "扬沙"
},
{
"wid": "31",
"weather": "强沙尘暴"
},
{
"wid": "53",
"weather": "霾"
}
],
"error_code": 0
}
haoservice提供天气查询数据接口:[url]http://www.haoservice.com/docs/6[/url]
根据城市名(IP)查询天气
演示示例代码:
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();
}
}
}
支持格式:json
http请求方式:GET POST
DEMO: http://apis.haoservice.com/weather?cityname=北京&key=您申请的KEY
参数说明:
名称 类型 是否必须 说明
Cityname(IP) string Y 城市名,如:"北京"
dtype string Y 返回数据格式:json
key string Y 你申请的key
返回示例:
{
"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": ""/*干燥指数*/
},
……
"day_20140326": {
"temperature": "10℃~19℃",
"weather": "多云",
"weather_id": {
"fa": "01",
"fb": "01"
},
"wind": "南风微风",
"week": "星期三",
"date": "20140326"
},
"day_20140327": {
"temperature": "11℃~20℃",
"weather": "阴转多云",
"weather_id": {
"fa": "02",
"fb": "01"
},
"wind": "南风微风转无持续风向微风",
"week": "星期四",
"date": "20140327"
}
}
}
}
天气种类及标识列表
支持格式:json
http请求方式:GET POST
DEMO: http://apis.haoservice.com/weather/uni?key=您申请的KEY
参数说明:
名称 类型 是否必须 说明
key string Y 你申请的key
返回示例:
{
"resultcode": "200",
"reason": "successed",
"result": [
{
"wid": "00",
"weather": "晴"
},
{
"wid": "01",
"weather": "多云"
},
{
"wid": "02",
"weather": "阴"
},
{
"wid": "03",
"weather": "阵雨"
},
{
"wid": "04",
"weather": "雷阵雨"
},
{
"wid": "05",
"weather": "雷阵雨伴有冰雹"
},
……
{
"wid": "30",
"weather": "扬沙"
},
{
"wid": "31",
"weather": "强沙尘暴"
},
{
"wid": "53",
"weather": "霾"
}
],
"error_code": 0
}
haoservice提供天气查询数据接口:[url]http://www.haoservice.com/docs/6[/url]