# :-: 介绍
* 本接口只能查询当天天气,不支持自动获取地址。
* 本接口采用中国天气网做接口,所以获取的时候会偏慢。
# :-: 代码说明
* 本接口采用GET和post方式提交,JSON返回方式返回信息。
* 提交地址:`https://api.berfen.com/api/tq.php`
## :-: 在线测试
* [https://api.berfen.com/api/tq.php?city=北京](https://api.berfen.com/api/tq.php?city=%E5%8C%97%E4%BA%AC)
## :-: 提交参数说明
| 参数 | 示例 | 说明 |
| --- | --- | --- |
| GET/POST | | 提交方式为get和post |
| city | 北京| 需要查询的地址,可为省、镇、市、县 |
## 返回参数说明
| 参数 | 示例 | 说明 |
| --- | --- | --- |
| JSON |{"code":200,"city":"北京","high":"26℃","low":"19℃","weather":"小雨","fx":"南风","ts":"相对今天出现了较大幅度降温,较易发生感冒,体质较弱的朋友请注意适当防护。"}| 返回方式为json数据 |
| code | 200 | 返回判断,200就是成功,其他的数字就是失败 |
| msg | | 返回信息,返回成功的信息和失败的原因 |
|city| 北京 | 查询的地址 |
|high|26℃|最高温度|
|low|19℃|最低温度|
|weather|小雨|天气状况|
|fx|南风|风向|
|ts|相对今天出现了较大幅度降温,较易发生感冒,体质较弱的朋友请注意适当防护。|温馨提示|
## :-: 返回代码示例
~~~
{
"code": 200,
"city": "北京",
"high": "26℃",
"low": "19℃",
"weather": "小雨",
"fx": "南风",
"ts": "相对今天出现了较大幅度降温,较易发生感冒,体质较弱的朋友请注意适当防护。"
}
~~~
## :-: iApp代码示例
~~~
t()
{
ug(1,"text",city)
//获取编辑框ID为1的内容
ss("https://api.berfen.com/tq.php?city="+city,url)
hs(url,url)
json(url,url)
json(url,"get","code",code)
//成功事件
json(url,"get","city",city)
//城市
json(url,"get","high",high)
//最高温度
json(url,"get","low",low)
//最低温度
json(url,"get","weather",weather)
//天气
json(url,"get","fx",fx)
//风向
json(url,"get","ts",ts)
//温馨提示,防感冒
ufnsui()
{
//将内容设置到文本上
us(7,"text",code)
us(8,"text",city)
us(9,"text",high)
us(10,"text",low)
us(11,"text",weather)
us(12,"text",fx)
us(13,"text",ts)
}
}
~~~