コード例 #1
0
ファイル: WeatherController.php プロジェクト: roman1970/lis
 public function actionGetGMWeather()
 {
     $cities = Cities::findAll(['country_id' => 0]);
     //$customers = Customer::findAll(['age' => 30, 'status' => 1]);
     // var_dump($cities); exit;
     foreach ($cities as $city) {
         echo $city->name;
         $ch = curl_init();
         $url = "{$city->weather_link}";
         curl_setopt($ch, CURLOPT_URL, $url);
         //curl_setopt($ch, CURLOPT_HEADER, 1); // читать заголовок
         //curl_setopt($ch, CURLOPT_NOBODY, 1); // читать ТОЛЬКО заголовок без тела
         $result = curl_exec($ch);
         curl_close($ch);
         // $content = file_get_contents($city->weather_link);
         $clearedDatas = $this->clearDatas($result, 'Атмосферное давление', ' ');
         // var_dump($clearedDatas); exit;
         $this->putDatasInTable($clearedDatas, $city);
     }
 }