Login   Register  
PHP Classes
elePHPant
Icontem

File: demos/001.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tom Schaefer  >  Wunderground Weather API  >  demos/001.php  >  Download  
File: demos/001.php
Role: Example script
Content type: text/plain
Description: using api
Class: Wunderground Weather API
Retrieve weather forecasts with Wunderground API
Author: By
Last change: add examples
Date: 1 year ago
Size: 1,918 bytes
 

Contents

Class file image Download
<?php 

header
("Content-Type: text/html; charset=utf-8");

include_once 
'../api.wunderground.classes.inc.php';

# to get an api key register here http://www.wunderground.com/weather/api/

$which 4;

# loading results by language or iso code
$weather WundergroundWeather::getInstance("DE")
         ->
apikey("--your api key here---");

switch(
$which){
    case 
0:
        
$weather->Geolookup()->CityCountry("Germany""Erftstadt");
        break;
    case 
1:
        
$weather->Forecast()->CityCountry("Germany""Erftstadt");
        break;
    case 
2:
        
$weather->Forecast10Day()->CityCountry("Germany""Erftstadt");
        break;
    case 
3:
        
$weather->History("20121201")->CityCountry("Germany""Erftstadt");
        break;
    case 
4
                
// returns binary GIF image data
        
$weather->Layers()
            ->
Radar(array("width"=>200"height"=>200))
            ->
CityCountry("MI""Ann_Arbor");
              
        break;
    case 
41:
        
$weather->Layers()
            ->
Satellite(array("width"=>200"height"=>200))
            ->
CityCountry("MI""Ann_Arbor");
        break;
    case 
5:
        
$weather->Alerts()->CityCountry("Germany""Erftstadt");
        break;
    case 
6:
        
$weather->Almanac()->CityCountry("Germany""Erftstadt");
        break;
    case 
7:
        
$weather->Conditions()->CityCountry("Germany""Erftstadt");
        break;
    case 
8:
        
$weather->Planner("2012122710")->CityCountry("Germany""Erftstadt");
        break;
    case 
9:
        
$weather->Astronomy()->CityCountry("Germany""Erftstadt");
        break;
    case 
10:
        
$weather->Satellite()->CityCountry("Germany""Erftstadt");
        break;
    case 
11:
        
$weather->Hourly()->CityCountry("Germany""Erftstadt");
        break;
    case 
12:
        
$weather->Hourly10Day()->CityCountry("Germany""Erftstadt");
        break;
    case 
13:
        
$weather->Yesterday()->CityCountry("Germany""Erftstadt");
        break;
}

$weather->doRequest();
$result $weather->getResult();

echo 
sprintf("<pre>%s</pre>"print_r($resulttrue));