PHP code example of xiaobinqt / aweather

1. Go to this page and download the library: Download xiaobinqt/aweather library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xiaobinqt / aweather example snippets


use Xiaobinqt\Weather\Weather;

// 高德开放平台应用 API Key
$key = 'xxx';
$w = new Weather($key);

$response = $w->getWeather('深圳');

{
    "status": "1",
    "count": "1",
    "info": "OK",
    "infocode": "10000",
    "forecasts": [
        {
            "city": "深圳市",
            "adcode": "440300",
            "province": "广东",
            "reporttime": "2019-06-29 15:15:36",
            "casts": [
                {
                    "date": "2019-06-29",
                    "week": "6",
                    "dayweather": "阵雨",
                    "nightweather": "多云",
                    "daytemp": "33",
                    "nighttemp": "28",
                    "daywind": "无风向",
                    "nightwind": "无风向",
                    "daypower": "≤3",
                    "nightpower": "≤3"
                },
                {
                    "date": "2019-06-30",
                    "week": "7",
                    "dayweather": "大雨",
                    "nightweather": "大雨",
                    "daytemp": "32",
                    "nighttemp": "28",
                    "daywind": "无风向",
                    "nightwind": "无风向",
                    "daypower": "≤3",
                    "nightpower": "≤3"
                },
                {
                    "date": "2019-07-01",
                    "week": "1",
                    "dayweather": "大雨",
                    "nightweather": "大雨",
                    "daytemp": "31",
                    "nighttemp": "27",
                    "daywind": "无风向",
                    "nightwind": "无风向",
                    "daypower": "≤3",
                    "nightpower": "≤3"
                },
                {
                    "date": "2019-07-02",
                    "week": "2",
                    "dayweather": "大雨-暴雨",
                    "nightweather": "大雨-暴雨",
                    "daytemp": "31",
                    "nighttemp": "26",
                    "daywind": "东南",
                    "nightwind": "东南",
                    "daypower": "4",
                    "nightpower": "4"
                }
            ]
        }
    ]
}