PHP code example of aiteemo / weather

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

    

aiteemo / weather example snippets



use Aiteemo\Weather\Weather;
$key        = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';
$weather    = new Weather($key);


use Aiteemo\Weather\Weather;
$key      = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';
$weather  = new Weather($key);

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

// 或者直接调用:getLiveWeather(version >= 0.0.2)
// $response = $weather->getLiveWeather('深圳'); 


use Aiteemo\Weather\Weather;
$key      = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';
$weather  = new Weather($key);

$response = $weather->getWeather('深圳', 'all');

// 或者直接调用:getForecastsWeather(version >= 0.0.2)
// $response = $weather->getForecastsWeather('深圳'); 


use Aiteemo\Weather\Weather;
$key      = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx';
$weather  = new Weather($key);
$response = $weather->getWeather('深圳', 'all', 'xml');