如何做一个api接口?
962
2022-10-25
本文目录一览:
中国国家气象局天气预报接口总共提供了三个:
最详细的信息来自第三个接口。上面url中的101010100是城市代码,这里是北京的城市代码。只需要改变城市代码,就可以得到所在城市的天气信息。笔者在福州,所以选择的城市代码是福州101230101。
在浏览器上输入url:得到信息,天气信息是json的数据格式,数据如
{"weatherinfo":{"city":"福州","city_en":"fuzhou","date_y":"2012年5月14 日","date":"","week":"星期 一","fchh":"08","cityid":"101230101","temp1":"29℃~23℃","temp2":"26℃~20℃","temp3":"24℃~20℃","temp4":"25℃~20℃","temp5":"24℃~21℃","temp6":"25℃~22℃","tempF1":"84.2℉~73.4℉","tempF2":"78.8℉~68℉","tempF3":"75.2℉~68℉","tempF4":"77℉~68℉","tempF5":"75.2℉~69.8℉","tempF6":"77℉~71.6℉","weather1":" 阵雨转中雨","weather2":"中雨转小雨","weather3":"小雨","weather4":"小雨","weather5":"小雨 转阵雨","weather6":"阵雨转小 雨","img1":"3","img2":"8","img3":"8","img4":"7","img5":"7","img6":"99","img7":"7","img8":"99","img9":"7","img10":"3","img11":"3","img12":"7","img_single":"3","img_title1":" 阵雨","img_title2":"中雨","img_title3":"中雨","img_title4":"小雨","img_title5":" 小雨","img_title6":"小雨","img_title7":"小雨","img_title8":"小雨","img_title9":" 小雨","img_title10":"阵雨","img_title11":"阵雨","img_title12":"小 雨","img_title_single":"阵雨","wind1":"微风","wind2":"微风","wind3":"微 风","wind4":"微风","wind5":"微风","wind6":"微风","fx1":"微风","fx2":"微风","fl1":"小 于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3 级","index":"热","index_d":"天气较热,建议着短裙、短裤、短套装、T恤等夏季服装。年老体弱者宜着长袖衬衫和单 裤。","index48":"暖","index48_d":"较凉爽,建议着长袖衬衫加单裤等春秋过渡装。年老体弱者宜着针织长袖衬衫、马甲和长 裤。","index_uv":"弱","index48_uv":"最弱","index_xc":"不宜","index_tr":"适 宜","index_co":"较不舒 适","st1":"27","st2":"21","st3":"24","st4":"18","st5":"22","st6":"18","index_cl":" 较不宜","index_ls":"不太适宜","index_ag":"不易发"}}[/code]
我们可以解析json数据去得到自己想用的天气信息。
天气信息解释:
{
"weatherinfo":{
!-- 基本信息 --
"city":"福州",
"city_en":"fuzhou",
"date_y":"2012年5月14日",
"date":"",
"week":"星期一",
"fchh":"08",
"cityid":"101230101",
!-- 从今天开始到第六天的每天的天气情况,这里的温度是摄氏温度 --
"temp1":"29℃~23℃","temp2":"26℃~20℃","temp3":"24℃~20℃","temp4":"25℃~20℃","temp5":"24℃~21℃","temp6":"25℃~22℃",
!-- 从今天开始到第六天的每天的天气情况,这里的温度是华氏温度 --
"tempF1":"84.2℉~73.4℉","tempF2":"78.8℉~68℉","tempF3":"75.2℉~68℉","tempF4":"77℉~68℉","tempF5":"75.2℉~69.8℉","tempF6":"77℉~71.6℉",
!-- 天气描述 --
"weather1":"阵雨转中雨","weather2":"中雨转小雨","weather3":"小雨","weather4":"小雨","weather5":"小雨转阵雨","weather6":"阵雨转小雨",
!-- 天气描述图片序号 --
"img1":"3","img2":"8","img3":"8","img4":"7","img5":"7","img6":"99","img7":"7","img8":"99","img9":"7","img10":"3","img11":"3","img12":"7","img_single":"3",
!-- 图片名称 --
"img_title1":"阵雨","img_title2":"中雨","img_title3":"中雨","img_title4":"小雨","img_title5":"小雨","img_title6":"小雨","img_title7":"小雨","img_title8":"小雨","img_title9":"小雨","img_title10":"阵雨","img_title11":"阵雨","img_title12":"小雨","img_title_single":"阵雨",
!-- 风速描述 --
"wind1":"微风","wind2":"微风","wind3":"微风","wind4":"微风","wind5":"微风","wind6":"微风","fx1":"微风","fx2":"微风",
!-- 风速级别描述 --
"fl1":"小于3级","fl2":"小于3级","fl3":"小于3级","fl4":"小于3级","fl5":"小于3级","fl6":"小于3级",
!-- 今天穿衣指数 --
"index":"热",
"index_d":"天气较热,建议着短裙、短裤、短套装、T恤等夏季服装。年老体弱者宜着长袖衬衫和单裤。",
!-- 48小时穿衣指数 --
"index48":"暖","index48_d":"较凉爽,建议着长袖衬衫加单裤等春秋过渡装。年老体弱者宜着针织长袖衬衫、马甲和长裤。",
!-- 紫外线及48小时紫外线 --
"index_uv":"弱","index48_uv":"最弱",
!-- 洗车 --
"index_xc":"不宜",
!-- 旅游 --
"index_tr":"适宜",、
!-- 舒适指数 --
"index_co":"较不舒适",
"st1":"27","st2":"21","st3":"24","st4":"18","st5":"22","st6":"18",
!-- 晨练 --
"index_cl":"较不宜",
!-- 晾晒 --
"index_ls":"不太适宜",
!-- 过敏 --
"index_ag":"不易发"
}
}
我今天也收到客户抱怨了,上中国天气网查看到了一个公告,看样子是API要变的节奏:
为更好地为用户提供气象数据服务,新版气象数据开放平台于2014年11月17日正式上线。
新用户可在线注册帐户,详细填写用户资料,按照申请流程提示申请数据接口,审核通过后,系统会自动分发密钥。新用户API数据接口通过审核后一年有效,逾期未续约将自动失效,API数据产品类型详见开放平台产品中心。
已申请并开通接口的老用户可继续使用原有API接口,原有API接口自今日起一年内有效,于2015年11月16日自动关闭,如有使用需要,建议老用户在接口关闭之前申请新API接口,申请流程及具体说明参见新用户申请。
请广大开发者相互转告,我们一直努力,为大家提供不断优化的气象数据服务
天气预报API接口是气象服务商为客户提供服务的唯一接口。拿墨迹赤必为例,跟客户充分沟通后了解客户的实际需求,从而对现有的数据进行调整,符合客户的需求形成API接口,让客户接入,这样就形成了一个完整的服务。所以说API接口并不是一个很神秘的东西,只不过是企业和客户之间的一条服务纽带。
哥们,我也刚发现了这个问题,今天是15号,可数据还是12号的!截图为证!大家被气象局坑了!
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~