天气查询
获取最近天气情况
基本说明:
接口地址:https://www.apiopen.top/weatherApi
返回格式:json
请求方式:get/post
请求示例:https://www.apiopen.top/weatherApi?city=%E4%B8%8A%E6%B5%B7
请求参数说明:
名称 类型 必填 说明
city String 必填 要查询的城市
返回参数说明:
名称 类型 说明
code int 状态码
message string 提示消息
result array 结果集合
JSON返回示例:
{
	"code": 200,
	"msg": "成功!",
	"data": {
		"yesterday": {
			"date": "20日星期四",
			"high": "高温 25℃",
			"fx": "东南风",
			"low": "低温 21℃",
			"fl": "\u003c![CDATA[\u003c3级]]\u003e",
			"type": "小雨"
		},
		"city": "上海",
		"aqi": null,
		"forecast": [{
			"date": "21日星期五",
			"high": "高温 24℃",
			"fengli": "\u003c![CDATA[3-4级]]\u003e",
			"low": "低温 20℃",
			"fengxiang": "东北风",
			"type": "小雨"
		}, {
			"date": "22日星期六",
			"high": "高温 28℃",
			"fengli": "\u003c![CDATA[3-4级]]\u003e",
			"low": "低温 20℃",
			"fengxiang": "东北风",
			"type": "多云"
		}, {
			"date": "23日星期天",
			"high": "高温 26℃",
			"fengli": "\u003c![CDATA[3-4级]]\u003e",
			"low": "低温 20℃",
			"fengxiang": "东北风",
			"type": "多云"
		}, {
			"date": "24日星期一",
			"high": "高温 27℃",
			"fengli": "\u003c![CDATA[3-4级]]\u003e",
			"low": "低温 22℃",
			"fengxiang": "东南风",
			"type": "阴"
		}, {
			"date": "25日星期二",
			"high": "高温 26℃",
			"fengli": "\u003c![CDATA[4-5级]]\u003e",
			"low": "低温 22℃",
			"fengxiang": "东南风",
			"type": "中雨"
		}],
		"ganmao": "各项气象条件适宜,无明显降温过程,发生感冒机率较低。",
		"wendu": "25"
	}
}
服务级错误码参照
错误码 说明
400 参数错误
完整教学代码示例
<?php
/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2019/3/15 17:50
 */
//----------------------------------
// peakchao 天气查询
//----------------------------------
$apiUrl = 'https://www.apiopen.top/weatherApi?city=%E4%B8%8A%E6%B5%B7';
var_dump(json_decode(file_get_contents($apiUrl),true));