PHP code example of canducci / weather

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

    

canducci / weather example snippets


"canducci/weather": "0.1.*"

$items = cities('Sao Paulo');
return $items->getJson();

$item = forecast(244);
return $item->getJson();

	
$items = Weather::cities('Sao Paulo');
foreach ($items as $key => $value) 
{
    echo sprintf('<p>%s %s %s</p>',
            $value->getId(), 
            $value->getName(), 
            $value->getUf());
}
	
$item = Weather::forecast(244, ForecastDay::Day4);    

//Dados da cidades
echo sprintf('<p>Id: %s</p><p> Cidade: %s</p><p> Uf: %s</p>
              <p>Data última atualização: %s</p>',
            $item->getId(), 
            $item->getCity(), 
            $item->getUf(), 
            $item->getUpdated()->format('d/m/Y'));

//Dados da previsões
foreach ($item->getDates() as $key => $value) 
{
    echo sprintf('<p>Data: %s</p><p>IUV: %s</p><p>Minima: %s</p>
                  <p>Maxima: %s</p><p>Status: %s - %s</p>', 
        $value->getDate()->format('d/m/Y'),
        $value->getIuv(), 
        $value->getMin(),
        $value->getMax(),
        $value->getTime()->getSigla(),
        $value->getTime()->getDescription());
}



	ather = new Canducci\Weather\Weather(new Canducci\Weather\WeatherClient());
	
	//busca de cidades
	echo $weather->cities('Sao Paulo')->getJson();
	//busca da previsão do tempo
	echo $weather->forecast(244)->getJson();