PHP code example of ecss / weather

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

    

ecss / weather example snippets


use Ecss\Weather\Weather;

$key = 'xxxxxxxxxxxxxxxx';

$weather = new Weather($key);

$response = $weather->getLiveWeather('重庆');

$response = $weather->getForecastsWeather('重庆');

$response = $weather->getLiveWeather('重庆', 'xml');

    .
    .
    .
     'weather' => [
        'key' => env('WEATHER_API_KEY'),
    ],

    .
    .
    .
    public function edit(Weather $weather) 
    {
        $response = $weather->getLiveWeather('重庆');
    }
    .
    .
    .

    .
    .
    .
    public function edit() 
    {
        $response = app('weather')->getLiveWeather('重庆');
    }
    .
    .
    .

xml
<response>
    <status>1</status>
    <count>1</count>
    <info>OK</info>
    <infocode>10000</infocode>
    <lives type="list">
        <live>
            <province>重庆</province>
            <city>重庆市</city>
            <adcode>500000</adcode>
            <weather>阴</weather>
            <temperature>11</temperature>
            <winddirection>西北</winddirection>
            <windpower>4</windpower>
            <humidity>82</humidity>
            <reporttime>2018-11-07 15:00:00</reporttime>
        </live>
    </lives>
</response>