Reseña de Olmo: Luminoso coming-of-age de Fernando Eimbcke | A través de la mirada de un adolescente obligado a crecer antes de tiempo, el director mexicano construye en Olmo su obra más madura... Leer más
Reseña The Invite: El amargo despertar de dos décadas de amor | A partir de un material teatral ya conocido, Olivia Wilde construye en The Invite una de las piezas de cámara más... Leer más
header("Content-Type: text/html; charset=utf-8");
class Get_Playing_Now {
private $apiKey;
public function __construct() {
$this->apiKey = '3aaf174e570b19f41b4f52f0df9becad';
$this->cacheFileName = 'json.cache.playingNow.txt';
$this->cacheUpdateMin = 80;
}
public function get_data($page) {
if (!file_exists($this->cacheFileName) || filemtime($this->cacheFileName) + ($this->cacheUpdateMin * 60) < time()) {
$url = 'https://api.themoviedb.org/3/movie/now_playing?api_key='.$this->apiKey.'&language=es-ES&page='.$page;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
$datasearch = json_decode($data, true);
curl_close($curl);
file_put_contents($this->cacheFileName, $data);
if (!empty($datasearch))
return $datasearch['results'];
else
return null;
}
else {
$datasearch = json_decode(file_get_contents($this->cacheFileName), true);
if (!empty($datasearch))
return $datasearch['results'];
else
return null;
}
}
public static function slugify($text, string $divider = '-') {
$text = preg_replace('~[^\pL\d]+~u', $divider, $text);
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
$text = preg_replace('~[^-\w]+~', '', $text);
$text = trim($text, $divider);
$text = preg_replace('~-+~', $divider, $text);
$text = strtolower($text);
if (empty($text))
return 'n-a';
return $text;
}
}
?>