Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Silviu Stan  >  Google Weather API  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: Google Weather API
Get a location weather forecast from Google
Author: By
Last change:
Date: 2010-02-10 01:01
Size: 683 bytes
 

Contents

Class file image Download
<?php
require_once('google_weather_api.php');

$weather = new weather();
if (!empty(
$_GET['loc'])) {
    
$weather->location $_GET['loc'];
}
$weather->get();
if(
$weather->error){
    die(
'We couldn\'t find your location.');
}else{
    echo 
'
    <div id="currentWeather">
        <h1>Now in '
.ucwords($weather->location).': '.$weather->current->temp_c['data'].' &#8451;</h1>
        <img src="http://www.google.com/' 
.$weather->current->icon['data'] . '"/>
        <p>'
.$weather->current->condition['data'].'</p>
        <p>'
.$weather->current->humidity['data'].'</p>
        <p>'
.$weather->current->wind_condition['data'].'</p>
    </div>
    '
;
    
// display more days info
    // print_r($weather->nextdays);
    
$weather->display();
}