Esempio n. 1
0
 public static function getDynamicValues($type)
 {
     ini_set('memory_limit', '512M');
     ini_set("max_execution_time", "600");
     $file = public_path("upload/Tmp" . $type . ".json.gz");
     if ($type == "Cinemas") {
         $link = "https://api.kinohod.ru/api/data/1/eed7c723-0b90-3fc9-a3bc-bf235e907b35/cinemas.json.gz";
     } elseif ($type == "Seances") {
         $link = "https://api.kinohod.ru/api/data/1/eed7c723-0b90-3fc9-a3bc-bf235e907b35/seances/week.json.gz";
     } else {
         $link = "https://api.kinohod.ru/api/data/1/eed7c723-0b90-3fc9-a3bc-bf235e907b35/running/week.json.gz";
     }
     //dd($link);
     file_put_contents($file, fopen($link, 'r'));
     $fp = gzopen($file, "r");
     if ($fp != false) {
         $contents = gzread($fp, 134217720);
         $jsonArray = json_decode($contents, true);
         foreach ($jsonArray as $key => $value) {
             if ($type == "Cinemas") {
                 Cinemas::store($value);
             } elseif ($type == "Seances") {
                 Seances::store($value);
             } else {
                 Movies::store($value);
             }
         }
         gzclose($fp);
         unlink($file);
     } else {
         echo "404 not found";
     }
 }