/ Published in: JavaScript
Expand |
Embed | Plain Text
<?php // Author: Piotr Filipek // Email: [email protected] // Last Update: 12.11.2010 class GoogleWeather { protected $xml; public $now; public $days; public function __construct($state){ $this->weather = simplexml_load_file('http://www.google.com/ig/api?hl=pl&weather='.$state); $this->now = $this->now(); $this->days = $this->days(); } public function now(){ return array( 'condition' => $this->weather->weather->current_conditions[0]->condition['data'], 'temp_f' => $this->weather->weather->current_conditions[0]->temp_f['data'], 'temp_c' => $this->weather->weather->current_conditions[0]->temp_c['data'], 'humidity' => $this->weather->weather->current_conditions[0]->humidity['data'], 'icon' => $this->weather->weather->current_conditions[0]->icon['data'], 'wind_condition' => $this->weather->weather->current_conditions[0]->wind_condition['data'] ); } public function days(){ $days = array(); foreach($this->weather->weather[0]->forecast_conditions as $conditions){ $days[] = array( 'name' => $conditions->day_of_week['data'][0], 'low' => $conditions->low['data'][0], 'high' => $conditions->high['data'][0], 'icon' => "http://google.com".$conditions->icon['data'][0], 'condition' => $conditions->condition['data'][0], ); } return $days; } } ?>
You need to login to post a comment.
