天气查询

1、使用
DEMO
2、查询说明

获取城市/地区的天气信息,比如:天气情况、温度、风向、风力、空气湿度等天气信息。

3、接口使用
http://www.xapi.ltd/api/weather/weather?uid=195&appkey=24be320a26da4712263b5d380946a116f77660ba&address=南宁
http://www.xapi.ltd/api/weather/weather?uid=195&appkey=24be320a26da4712263b5d380946a116f77660ba&address=南宁

4、请求参数
参数 必须 类型 描述
uid string 用户UID点击查看
appkey string 用户页面的APPKEY点击查看
address string 要搜索的城市/地区名称
5、返回参数
{
	"status": 1,
	"result": [{
		"province": "广西",
		"city": "南宁市",
		"adcode": "450100",
		"weather": "多云",
		"temperature": "29",
		"winddirection": "东北",
		"windpower": "≤3",
		"humidity": "54",
		"reporttime": "2019-09-20 18:50:11"
	}],
	"code": 0,
	"msg": "查询成功"
}
参数 必须 类型 描述
static int 接口响应结果:0失败;1成功
msg string 响应描述
code int 错误码,一般为0
result object 返回查询结果信息
6、代码示例
//接口地址
$api_url = "http://www.xapi.ltd";
//uid
$uid = "195";
//appkey
$appkey = "24be320a26da4712263b5d380946a116f77660ba";
//要搜索的身份证号码
$address = "南宁";
$url = $api_url."/api/weather?uid=".$uid."&appkey=".$appkey."&address=".$address;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
//输出返回结果
$result = json_decode($result,true);
var_dump($result);
var api_url = "http://www.xpi.ltd";
var uid = "195";
var appkey = "24be320a26da4712263b5d380946a116f77660ba";
var address = "南宁";
$.ajax({
	type:"post",
	url: api_url+"/api/weather",
	data: {"appkey":appkey,"uid":uid,"address":address},
	success: function(data){
		console.log(data);
	},
	error: function(){
		alert("网络错误~请稍后再试");
	},
	dataType: "json"	      		
});

0.010081s