PHP code example of her-cat / weather

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

    

her-cat / weather example snippets


use HerCat\Weather\Weather;

$key = 'xxxxxxxxxxxxxxxxxxxxxx';

$weather = new Weather($key);

$response = $weather->getLiveWeather('深圳');

$response = $weather->getForecastsWeather('深圳', 'json');

$response = $weather->getLiveWeather('深圳', 'xml');

array|string getLiveWeather(string $city, string $format = 'json')
array|string getForecastsWeather(string $city, string $format = 'json')

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

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

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