<?php

error_reporting(-1);
print PHP_EOL . 'update movie information is starting...' . PHP_EOL;
const ALLOW_ACCESS = true;
$loader = (require_once __DIR__ . '/../vendor/autoload.php');
$cache = new \App\CachingHelper();
try {
    $movieListObj = new App\MovieHelper('2015-01-01', 'revenue.desc', 1);
    print 'calling movie service...' . PHP_EOL;
    $movieListObj->setMovieList();
    print 'updating movie list with revenue and additional info...' . PHP_EOL;
    $movieListObj->updateRevenueMovieList();
    $movieList = $movieListObj->getMovieList();
    print 'updating the cache file...' . PHP_EOL;
    $cache->updateCache($movieList);
    print 'finished updating the cache file!' . PHP_EOL;
} catch (Exception $e) {
    //assumes mail will work
    error_log($e->getMessage());
    mail(ADMIN_EMAIL, 'Exception thrown', $e->getMessage());
    print 'sorry could not connect to the Movie DB Serverice. Error: ' . $e->getMessage() . PHP_EOL;
}
Beispiel #2
0
<?php

const ALLOW_ACCESS = true;
$loader = (require_once __DIR__ . '/vendor/autoload.php');
// Serve from the cache if it is younger than $cachetime
$cache = new \App\CachingHelper();
if ($cache->isCached()) {
    $movieList = json_decode(file_get_contents($cache->getCache()));
} else {
    try {
        $movieListObj = new App\MovieHelper('2015-01-01', 'revenue.desc', 1);
        $movieListObj->setMovieList();
        $movieListObj->updateRevenueMovieList();
        $movieList = $movieListObj->getMovieList();
        $cache->updateCache($movieList);
    } catch (Exception $e) {
        //assumes mail will work
        error_log($e->getMessage());
        mail(ADMIN_EMAIL, 'Exception thrown', $e->getMessage());
        echo 'sorry could not connect to the Movie DB Serverice.';
    }
}
try {
    (new App\View('index.html'))->render($movieList);
} catch (Exception $e) {
    (new app\view('error.html'))->render($e->getMessage());
}