PHP code example of dotimes / weather

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

    

dotimes / weather example snippets


use Dotimes\Weather\Weather;

$key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';

$weather = new Weather($key);

$response = $weather->getLiveWeather('上海');

$response = $weather->getLiveWeather('上海', 'xml');

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

	.
	.
	.
	public function edit(Weather $weather) 
	{
		$response = $weather->getLiveWeather('上海');
		$response = $weather->getForecastsWeather('上海');
	}
	.
	.
	.

	.
	.
	.
	public function edit() 
	{
		$response = app('weather')->getLiveWeather('上海');
		$response = app('weather')->getForecastsWeather('上海');
	}
	.
	.
	.


$response = $weather->getForecastsWeather('上海');
json
{
    "status": "1",
    "count": "1",
    "info": "OK",
    "infocode": "10000",
    "forecasts": [
        {
            "city": "上海市",
            "adcode": "310000",
            "province": "上海",
            "reporttime": "2019-03-26 00:18:46",
            "casts": [
                {
                    "date": "2019-03-25",
                    "week": "1",
                    "dayweather": "阴",
                    "nightweather": "晴",
                    "daytemp": "14",
                    "nighttemp": "10",
                    "daywind": "西南",
                    "nightwind": "西南",
                    "daypower": "≤3",
                    "nightpower": "≤3"
                },
                {
                    "date": "2019-03-26",
                    "week": "2",
                    "dayweather": "多云",
                    "nightweather": "多云",
                    "daytemp": "22",
                    "nighttemp": "13",
                    "daywind": "南",
                    "nightwind": "南",
                    "daypower": "4",
                    "nightpower": "4"
                },
                {
                    "date": "2019-03-27",
                    "week": "3",
                    "dayweather": "小雨",
                    "nightweather": "小雨",
                    "daytemp": "17",
                    "nighttemp": "13",
                    "daywind": "东北",
                    "nightwind": "东北",
                    "daypower": "4",
                    "nightpower": "4"
                },
                {
                    "date": "2019-03-28",
                    "week": "4",
                    "dayweather": "中雨",
                    "nightweather": "小雨",
                    "daytemp": "17",
                    "nighttemp": "10",
                    "daywind": "北",
                    "nightwind": "北",
                    "daypower": "4",
                    "nightpower": "4"
                }
            ]
        }
    ]
}