get() 공개 메소드

Creates 'GET' request.
public get ( string $url, array | string $data = null, array $headers = [], array $options = [] ) : Request
$url string target URL.
$data array | string if array - request data, otherwise - request content.
$headers array request headers.
$options array request options.
리턴 Request request instance.
예제 #1
0
 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;
     }
 }
예제 #2
0
 private function _getXML()
 {
     $client = new Client();
     $response = $client->get($this->url)->send();
     if ($response->isOk) {
         return $response->data['channel'];
     } else {
         return false;
     }
 }
예제 #3
0
 private function send($url, $data)
 {
     $params = ArrayHelper::merge(['login' => $this->login, 'pass' => $this->pass], $data);
     return $this->_client->get($url, $params)->send();
 }