PHP code example of michael-wu / weather

1. Go to this page and download the library: Download michael-wu/weather 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/ */

    

michael-wu / weather example snippets


    $response = $weather->getWeather('深圳');
angular2
    {
        "status": "1", 
        "count": "1", 
        "info": "OK", 
        "infocode": "10000", 
        "forecasts": [
            {
                "city": "深圳市", 
                "adcode": "440300", 
                "province": "广东", 
                "reporttime": "2018-08-21 11:00:00", 
                "casts": [
                    {
                        "date": "2018-08-21", 
                        "week": "2", 
                        "dayweather": "雷阵雨", 
                        "nightweather": "雷阵雨", 
                        "daytemp": "31", 
                        "nighttemp": "26", 
                        "daywind": "无风向", 
                        "nightwind": "无风向", 
                        "daypower": "≤3", 
                        "nightpower": "≤3"
                    }, 
                    {
                        "date": "2018-08-22", 
                        "week": "3", 
                        "dayweather": "雷阵雨", 
                        "nightweather": "雷阵雨", 
                        "daytemp": "32", 
                        "nighttemp": "27", 
                        "daywind": "无风向", 
                        "nightwind": "无风向", 
                        "daypower": "≤3", 
                        "nightpower": "≤3"
                    }, 
                    {
                        "date": "2018-08-23", 
                        "week": "4", 
                        "dayweather": "雷阵雨", 
                        "nightweather": "雷阵雨", 
                        "daytemp": "32", 
                        "nighttemp": "26", 
                        "daywind": "无风向", 
                        "nightwind": "无风向", 
                        "daypower": "≤3", 
                        "nightpower": "≤3"
                    }, 
                    {
                        "date": "2018-08-24", 
                        "week": "5", 
                        "dayweather": "雷阵雨", 
                        "nightweather": "雷阵雨", 
                        "daytemp": "31", 
                        "nighttemp": "26", 
                        "daywind": "无风向", 
                        "nightwind": "无风向", 
                        "daypower": "≤3", 
                        "nightpower": "≤3"
                    }
                ]
            }
        ]
    }

    <response>
        <status>1</status>
        <count>1</count>
        <info>OK</info>
        <infocode>10000</infocode>
        <lives type="list">
            <live>
                <province>广东</province>
                <city>深圳市</city>
                <adcode>440300</adcode>
                <weather>中雨</weather>
                <temperature>27</temperature>
                <winddirection>西南</winddirection>
                <windpower>5</windpower>
                <humidity>94</humidity>
                <reporttime>2018-08-21 16:00:00</reporttime>
            </live>
        </lives>
    </response>

    .
    .
    .
    public function edit(Weather $weather) 
    {
        $response = $weather->getWeather('深圳');
    }
    .
    .
    .

    .
    .
    .
    public function edit() 
    {
        $response = app('weather')->getWeather('深圳');
    }
    .
    .
    .