Skip to content

Tinywan/webman-weather

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webman weather plugin

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

🌈 基于高德开放平台的天气信息插件

安装

composer require tinywan/weather

使用

配置

在使用本扩展之前,你需要去 高德开放平台 注册账号,然后创建应用,获取应用的 API Key。

获取实时天气

$response = tinywan\Weather::liveWeather('杭州');

响应信息

{
    "status": "1",
    "count": "1",
    "info": "OK",
    "infocode": "10000",
    "lives": [
        {
            "province": "浙江",
            "city": "杭州市",
            "adcode": "330100",
            "weather": "",
            "temperature": "27",
            "winddirection": "",
            "windpower": "≤3",
            "humidity": "47",
            "reporttime": "2022-04-12 20:02:04"
        }
    ]
}

响应参数

live.png

获取近期天气预报

$response = tinywan\Weather::forecastsWeather('杭州');

响应信息

{
    "status": "1",
    "count": "1",
    "info": "OK",
    "infocode": "10000",
    "forecasts": [
        {
            "city": "杭州市",
            "adcode": "330100",
            "province": "浙江",
            "reporttime": "2022-04-12 20:02:04",
            "casts": [
                {
                    "date": "2022-04-12",
                    "week": "2",
                    "dayweather": "多云",
                    "nightweather": "",
                    "daytemp": "33",
                    "nighttemp": "19",
                    "daywind": "",
                    "nightwind": "",
                    "daypower": "4",
                    "nightpower": "4"
                },
                {
                    "date": "2022-04-13",
                    "week": "3",
                    "dayweather": "中雨",
                    "nightweather": "小雨",
                    "daytemp": "22",
                    "nighttemp": "16",
                    "daywind": "西北",
                    "nightwind": "西北",
                    "daypower": "4",
                    "nightpower": "4"
                },
                {
                    "date": "2022-04-14",
                    "week": "4",
                    "dayweather": "小雨",
                    "nightweather": "小雨",
                    "daytemp": "18",
                    "nighttemp": "16",
                    "daywind": "",
                    "nightwind": "",
                    "daypower": "4",
                    "nightpower": "4"
                },
                {
                    "date": "2022-04-15",
                    "week": "5",
                    "dayweather": "小雨",
                    "nightweather": "小雨",
                    "daytemp": "15",
                    "nighttemp": "11",
                    "daywind": "东北",
                    "nightwind": "东北",
                    "daypower": "4",
                    "nightpower": "4"
                }
            ]
        }
    ]
}

响应参数

forecast.png