public function updateWeather() { $client = new Client(); $response = $client->get('http://api.wunderground.com/api/fa62a2e2278b3297/conditions/q/PL/Lublin.json')->send(); if ($response->isOk) { $currentObs = $response->data['current_observation']; if (isset($currentObs['temp_c'])) { $this->temperature = $currentObs['temp_c']; } if (isset($currentObs['pressure_mb'])) { $this->pressure = $currentObs['pressure_mb']; } if (isset($currentObs['wind_kph'])) { $this->wind_speed = $currentObs['wind_kph']; } if (isset($currentObs['icon'])) { $this->conditions = $currentObs['icon']; } if (isset($currentObs['pressure_trend'])) { $this->pressure_trend = $currentObs['pressure_trend']; } if (isset($currentObs['observation_epoch'])) { $this->update_time = $currentObs['observation_epoch']; } if (isset($currentObs['feelslike_c'])) { $this->feels_like = $currentObs['feelslike_c']; } $this->save(); return true; } else { return false; } }
private function _getXML() { $client = new Client(); $response = $client->get($this->url)->send(); if ($response->isOk) { return $response->data['channel']; } else { return false; } }
private function send($url, $data) { $params = ArrayHelper::merge(['login' => $this->login, 'pass' => $this->pass], $data); return $this->_client->get($url, $params)->send(); }