Esempio n. 1
0
<?php

// A basic example of using the OpenWeatherMap library
// sudo php -S localhost:80 -t examples/
//
// curl localhost:80/basic.php
// require the Composer autoloader
require_once '../vendor/autoload.php';
// create a default instance of OpenWeatherMap
$openWeatherMap = new OpenWeatherMap\OpenWeatherMap();
// lets get the current weather for New York, US
$current = $openWeatherMap->getWeather(array('query' => 'New York,US'));
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Basic 01</title>
    </head>
    <body>
        <h2>The Weather in <?php 
echo $current->getCity()->getName();
?>
</h2>
        <table>
            <tr>
                <th>Temperature</th>
                <td><?php 
echo $current->getTemperature()->getValue();
?>
 <?php 
echo $current->getTemperature()->getUnit();
Esempio n. 2
0
<?php

// a basic example us using the OpenWeahtherMap library
// require the Composer autoloader
require_once '../vendor/autoload.php';
// create a default instance of OpenWeatherMap
$openWeatherMap = new OpenWeatherMap\OpenWeatherMap();
// get the daily weather for Berlin,DE
$weatherData = $openWeatherMap->getDaily(array('query' => 'Berlin,DE'));
echo '<pre>';
print_r($weatherData);
echo '</pre>';
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Basic 02</title>
    </head>
    <body>

        <table>
            <?php 
foreach ($weatherData->getForecast()->getTimes() as $time) {
    ?>
            <tbody>
                <tr>
                    <td colspan="2"><?php 
    echo $time->getDay();
    ?>
</td>
                </tr>