Commit 90a64aa4 authored by Nico Schallehn's avatar Nico Schallehn

test

parent 739b0bec
...@@ -2,16 +2,30 @@ ...@@ -2,16 +2,30 @@
ini_set("display_errors","On"); ini_set("display_errors","On");
error_reporting (E_ALL); error_reporting (E_ALL);
function jsonCacheDecoder($url){
$CacheFolderName = "JsonCache/";
exec("rm ".$CacheFolderName.date("y-W_",time()-14*24*3600)."* > /dev/null 2>&1");
exec("rm ".$CacheFolderName.date("y-W_",time()-1*24*3600)."* > /dev/null 2>&1");
if(!is_dir($CacheFolderName)){
exec( "mkdir ".$CacheFolderName);
}
$filename= date("y-W_",time()).md5($url).".json"; //TODO Cachetime Ändern
if(!file_exists($CacheFolderName.$filename)){
file_put_contents($CacheFolderName.$filename, file_get_contents($url));
}
return json_decode(file_get_contents($CacheFolderName.$filename), true);
}
$tmdbKey = "b1ddcc7d16281ce09f692896f882ba9d"; $tmdbKey = "b1ddcc7d16281ce09f692896f882ba9d";
$imdbID = "0489270"; $imdbID = "0489270";
$url = "https://api.themoviedb.org/3/find/tt".$imdbID."?external_source=imdb_id&api_key=".$tmdbKey."&language=de"; //$this->config["ApiKeys"]['Tmdb_Key'] $url = "https://api.themoviedb.org/3/find/tt".$imdbID."?external_source=imdb_id&api_key=".$tmdbKey."&language=de"; //$this->config["ApiKeys"]['Tmdb_Key']
echo $url; echo $url;
$tmdb = $this->jsonCacheDecoder($url); $tmdb = jsonCacheDecoder($url);
if(isset($tmdb["movie_results"])){ if(isset($tmdb["movie_results"])){
$tmdbURL="https://api.themoviedb.org/3/movie/".$tmdb["movie_results"][0]["id"]."?api_key=".$tmdbKey."&language=de&append_to_response=trailers"; $tmdbURL="https://api.themoviedb.org/3/movie/".$tmdb["movie_results"][0]["id"]."?api_key=".$tmdbKey."&language=de&append_to_response=trailers";
echo $tmdbURL.PHP_EOL; echo $tmdbURL.PHP_EOL;
$tmdbData1 = $this->jsonCacheDecoder($tmdbURL); $tmdbData1 = jsonCacheDecoder($tmdbURL);
var_dump($tmdbData1); var_dump($tmdbData1);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment