参数说明
名称 |
必填 |
类型 |
说明 |
city |
否 |
string |
输入城市或县区 |
ip |
否 |
string |
输入IP |
返回数据
{"data":{"yesterday":{"date":"30日星期三","high":"高温 4℃","fx":"西南风","low":"低温 -1℃","fl":"","type":"雨夹雪"},"city":"西安","forecast":[{"date":"31日星期四","high":"高温 7℃","fengli":"","low":"低温 -6℃","fengxiang":"西南风","type":"小雪"},{"date":"1日星期五","high":"高温 7℃","fengli":"","low":"低温 -4℃","fengxiang":"东北风","type":"多云"},{"date":"2日星期六","high":"高温 7℃","fengli":"","low":"低温 -3℃","fengxiang":"西南风","type":"多云"},{"date":"3日星期天","high":"高温 10℃","fengli":"","low":"低温 -1℃","fengxiang":"南风","type":"多云"},{"date":"4日星期一","high":"高温 8℃","fengli":"","low":"低温 -3℃","fengxiang":"东北风","type":"多云"}],"ganmao":"昼夜温差很大,易发生感冒,请注意适当增减衣服,加强自我防护避免感冒。","wendu":"2"},"status":1000,"desc":"OK"}
调用实例
自行调用
示例代码
<?php
header('Content-type:text/json;charset=utf-8;');
$city = $_GET['city'];
$result = file_get_contents("https://api.vvhan.com/api/weather?city=" . $city);
echo $result;
?>