コード例 #1
0
        $userLat = $IPInfoArray[0];
        $userLong = $IPInfoArray[1];
    } else {
        $userLat = $_GET['latitude'];
        $userLong = $_GET['longitude'];
    }
}
$forecast = new ForecastIO($apikey);
if ($userLat != null && $userLong != null) {
    $units = 'si';
    $_COOKIE['tempPref'] == 'F' ? $units = 'us' : pass;
    $condition = $forecast->getCurrentConditions($userLat, $userLong, $units);
    $weatherCondition = $condition->getIcon();
    // $weatherCondition = 'clear';
    $backgroundImageURL = './weather-backgrounds/' . $weatherCondition . '.jpg';
    $conditionLaterToday = $forecast->getForecastToday($userLat, $userLong, $units);
    $weatherConditionLater = $conditionLaterToday[7]->getIcon();
    if (in_array($weatherConditionLater, ['rain', 'snow', 'sleet'])) {
    }
    if (in_array($weatherCondition, ['clear-night', 'partly-cloudy-night'])) {
        $isNight = True;
    }
}
?>

    <div id="prefs_modal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">Preferences</h2>
コード例 #2
0
$units = 'auto';
// Can be set to 'us', 'si', 'ca', 'uk' or 'auto' (see forecast.io API); default is auto
$lang = 'en';
// Can be set to 'en', 'de', 'pl', 'es', 'fr', 'it', 'tet' or 'x-pig-latin' (see forecast.io API); default is 'en'
$forecast = new ForecastIO($api_key, $units, $lang);
// all default will be
// $forecast = new ForecastIO($api_key);
/*
 * GET CURRENT CONDITIONS
 */
$condition = $forecast->getCurrentConditions($latitude, $longitude);
echo 'Current temperature: ' . $condition->getTemperature() . "\n";
/*
 * GET HOURLY CONDITIONS FOR TODAY
 */
$conditions_today = $forecast->getForecastToday($latitude, $longitude);
echo "\n\nTodays temperature:\n";
foreach ($conditions_today as $cond) {
    echo $cond->getTime('H:i:s') . ': ' . $cond->getTemperature() . "\n";
}
/*
 * GET DAILY CONDITIONS FOR NEXT 7 DAYS
 */
$conditions_week = $forecast->getForecastWeek($latitude, $longitude);
echo "\n\nConditions this week:\n";
foreach ($conditions_week as $conditions) {
    echo $conditions->getTime('Y-m-d') . ': ' . $conditions->getMaxTemperature() . "\n";
}
/*
 * GET HISTORICAL CONDITIONS
 */
コード例 #3
0
ファイル: weather.php プロジェクト: kcunanan/claremontrise
$longitude = '-117.707591';
$units = 'auto';
// Can be set to 'us', 'si', 'ca', 'uk' or 'auto' (see forecast.io API); default is auto
$lang = 'en';
// Can be set to 'en', 'de', 'pl', 'es', 'fr', 'it', 'tet' or 'x-pig-latin' (see forecast.io API); default is 'en'
$forecast = new ForecastIO($api_key, $units, $lang);
// all default will be
// $forecast = new ForecastIO($api_key);
/*
 * GET CURRENT CONDITIONS
 */
//$condition = $forecast->getCurrentConditions($latitude, $longitude);
/*
 * GET HOURLY CONDITIONS FOR TODAY
 */
$temperature = $forecast->getForecastToday($latitude, $longitude);
$current_temp = $temperature[0]->getTemperature();
// foreach($conditions_today as $cond) {
//
//     //echo $cond->getTime('H:i:s') . ': ' . $cond->getTemperature(). "\n";
//     //echo "<br>";
//     if($cond->getTemperature() > $hi) {
//       $hi = $cond->getTemperature();
//     }
// }
/*
 * GET DAILY CONDITIONS FOR NEXT 7 DAYS
 */
$conditions_week = $forecast->getForecastWeek($latitude, $longitude);
echo "\n\nConditions this week:\n";
$count = 0;