Ejemplo n.º 1
1
<?php

require_once 'connection.php';
require_once 'models/movie-model.php';
$conn = getConnection();
$movieModel = new Movies($conn);
$id = '';
if (isset($_GET['id']) && $_GET['id'] != '') {
    //determines if there is anything after 'id'
    $id = $_GET['id'];
    //stores the id query string
    $movie = $movieModel->getMovieByID($id);
} else {
    die('Please put in an ID');
}
$imdbID = $movie[0]['imdb_id'];
$array = $movie[0];
$found = true;
if (empty($imdbID)) {
    $found = false;
    $jsonmovie = json_encode($array);
    $result = json_decode($jsonmovie, true);
} else {
    $url = "http://www.omdbapi.com/?i={$imdbID}&tomatoes=true";
    $json = file_get_contents($url);
    $result = json_decode($json, true);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>