public function testSearchActor() { /** * @covers \ */ $config = parse_ini_file('./api.ini'); $tmdb = new TMDB($config['apikey'], 'en'); $actors = $tmdb->searchPerson("johnny knoxville"); $this->assertCount(1, $actors); }
<?php include 'tmdb-api.php'; $root_name = "data"; $array = array(); if (!isset($_REQUEST['query']) || TRIM($_REQUEST['query']) == '') { $array["opcion"] = 2; $array["status_message"] = "The resource you requested could not be found."; echo json_encode($array); } else { $apikey = 'b452a69cd4b748e4c41a4109f4d91f8f'; $tmdb = new TMDB($apikey); // by simply giving $apikey it sets the default lang to 'en' $name = $_REQUEST['query']; $persons = $tmdb->searchPerson($name); $array["opcion"] = 1; if (sizeof($persons) == 0) { $array["results"] = array(); } else { foreach ($persons as $person) { $persona = $tmdb->getPerson($person->getID()); $know_for = array(); $movies = $persona->getMovieRoles(); for ($i = 0; $i < sizeof($movies) && $i < 4; $i++) { $know_for[] = array("title" => $movies[$i]->getMovieTitle()); } $personaje = array("name" => $persona->getName(), "id" => $persona->getID(), "known_for" => $know_for, "profile_path" => $persona->getProfile()); $array["results"][] = $personaje; } } echo json_encode($array);
<!DOCTYPE html> <html> <head> <title>API usage for Persons</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta charset="utf-8" /> </head> <body> <?php include "../tmdb-api.php"; $apikey = "Your API Key"; $tmdb = new TMDB($apikey, 'en', true); echo '<h2>API Usage for Persons examples</h2>'; // 1. Search Person echo '<ol><li><a id="searchPerson"><h3>Search Person</h3></a><ul>'; $persons = $tmdb->searchPerson("Johnny"); foreach ($persons as $person) { echo '<li>' . $person->getName() . ' (<a href="https://www.themoviedb.org/person/' . $person->getID() . '">' . $person->getID() . '</a>)</li>'; } echo '</ul></li><hr>'; // 2. Full Person Info echo '<li><a id="personInfo"><h3>Full Person Info</h3></a><ul>'; $person = $tmdb->getPerson(85); echo 'Now the <b>$person</b> var got all the data, check the <a href="http://code.octal.es/php/tmdb-api/class-Person.html">documentation</a> for the complete list of methods.<br><br>'; echo '<b>' . $person->getName() . '</b><ul>'; echo ' <li>ID: ' . $person->getID() . '</li>'; echo ' <li>Birthday: ' . $person->getBirthday() . '</li>'; echo ' <li>Popularity: ' . $person->getPopularity() . '</li>'; echo '</ul>...'; echo '<img src="' . $tmdb->getImageURL('w185') . $person->getProfile() . '"/>'; echo '</ul></li><hr>';
<?php include 'tmdb-api.php'; $root_name = "data"; $array = array(); if (!isset($_REQUEST['id']) || TRIM($_REQUEST['id']) == '') { $array["opcion"] = 2; $array["status_message"] = "The resource you requested could not be found."; echo json_encode($array); } else { $apikey = 'b452a69cd4b748e4c41a4109f4d91f8f'; $tmdb = new TMDB($apikey); // by simply giving $apikey it sets the default lang to 'en' $id = $_REQUEST['id']; $array["opcion"] = 1; $persona = $tmdb->getPerson($id); $cast = array(); foreach ($persona->getMovieRoles() as $movies_rol) { $movie = $tmdb->getMovie($movies_rol->getMovieID()); $cast[] = array("poster_path" => $movie->getPoster(), "release_date" => $movies_rol->getMovieReleaseDate(), "original_title" => $movie->getTitle(), "character" => $movies_rol->getCharacter()); } $array["cast"] = $cast; echo json_encode($array); }
<?php include "./bootstrap.php"; print_header(); $config = parse_ini_file('../api.ini'); if (!isset($config['apikey'])) { print '<p class="error">Error: Unable to locate api key, please contact administrator</p>'; } else { if ($_GET['search'] === 'Search' and isset($_GET['searchterm'])) { $searchterm = filter_var($_GET['searchterm'], FILTER_SANITIZE_ENCODED); // had issues with filter_var returning nullset so we make sure that we have data if (isset($searchterm) and $searchterm != false) { $tmdb = new TMDB($config['apikey'], 'en'); if ($_GET['type'] === 'Movie') { $movies = $tmdb->searchMovie($searchterm); if (count($movies) > 0) { // I like proper formatting in pages. It makes it easier on the eyes print_movieresults($movies); } else { echo '<p class="error">No Movies found with the terms ', $searchterm, '</p>'; } } elseif ($_GET['type'] === 'Actor') { $actors = $tmdb->searchPerson($searchterm); if (count($actors) > 0) { // I like proper formatting in pages. It makes it easier on the eyes print_actorresults($actors); } else { echo '<p class="error">No Actors found with the terms ', $searchterm, '</p>'; } } }
<!DOCTYPE html> <html> <head> <title>API usage for Movies</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta charset="utf-8" /> </head> <body> <?php include "../tmdb-api.php"; $apikey = "Your API Key"; $tmdb = new TMDB($apikey, 'en', true); echo '<h2>API Usage for Movies examples</h2>'; // 1. Search Movie echo '<ol><li><a id="searchMovie"><h3>Search Movie</h3></a><ul>'; $movies = $tmdb->searchMovie("underworld"); foreach ($movies as $movie) { echo '<li>' . $movie->getTitle() . ' (<a href="https://www.themoviedb.org/movie/' . $movie->getID() . '">' . $movie->getID() . '</a>)</li>'; } echo '</ul></li><hr>'; // 2. Full Movie Info echo '<li><a id="movieInfo"><h3>Full Movie Info</h3></a>'; $movie = $tmdb->getMovie(11); echo 'Now the <b>$movie</b> var got all the data, check the <a href="http://code.octal.es/php/tmdb-api/class-Movie.html">documentation</a> for the complete list of methods.<br><br>'; echo '<b>' . $movie->getTitle() . '</b><ul>'; echo ' <li>ID:' . $movie->getID() . '</li>'; echo ' <li>Tagline:' . $movie->getTagline() . '</li>'; echo ' <li>Trailer: <a href="https://www.youtube.com/watch?v=' . $movie->getTrailer() . '">link</a></li>'; echo '</ul>...'; echo '<img src="' . $tmdb->getImageURL('w185') . $movie->getPoster() . '"/></li>'; // 3. Now Playing Movies
/** * Reload the content of this class.<br> * Could be used to update or complete the information. * * @param TMDB $tmdb An instance of the API handler, necesary to make the API call. */ public function reload($tmdb) { $tmdb->getEpisode($this->getTVShowID(), $this->getSeasonNumber(), $this->getEpisodeNumber); }
/** * Reload the content of this class.<br> * Could be used to update or complete the information. * * @param TMDB $tmdb An instance of the API handler, necesary to make the API call. */ public function reload($tmdb) { return $tmdb->getSeason($this->getTVShowID(), $this->getSeasonNumber()); }
<?php include 'tmdb-api.php'; // Insert your api key of TMDB $apikey = '8e6b3ea147a291f833ea1ead9195b3f2'; $language = 'es'; $tmdb = new TMDB($apikey, $language); // by simply giving $apikey it sets the default lang to 'en' $movie_id = $_POST["id"]; $movie = $tmdb->getMovie($movie_id); echo '<h2>' . $movie->getTitle() . '</h2>'; echo "<p></p>"; echo "<p><iframe width='560' height='315' src='https://www.youtube.com/v/" . $movie->getTrailer() . "' style='border:none'></iframe></p>";
<!DOCTYPE html> <html> <head> <title>API usage for TVShows</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta charset="utf-8" /> </head> <body> <?php include "../tmdb-api.php"; $apikey = "Your API Key"; $tmdb = new TMDB($apikey, 'en', true); echo '<h2>API Usage for TVShow examples</h2>'; // 1. Search TVShow echo '<ol><li><a id="searchTVShow"><h3>Search TVShow</h3></a><ul>'; $tvShows = $tmdb->searchMovie("breaking bad"); foreach ($tvShows as $tvShow) { echo '<li>' . $tvShow->getTitle() . ' (<a href="https://www.themoviedb.org/tv/' . $tvShow->getID() . '">' . $tvShow->getID() . '</a>)</li>'; } echo '</ul></li><hr>'; // 2. Full Movie Info echo '<li><a id="tvShowInfo"><h3>Full TVShow Info</h3></a>'; $tvShow = $tmdb->getTVShow(1396); echo 'Now the <b>$tvShow</b> var got all the data, check the <a href="http://code.octal.es/php/tmdb-api/class-TVShow.html">documentation</a> for the complete list of methods.<br><br>'; echo '<b>' . $tvShow->getName() . '</b><ul>'; echo ' <li>ID:' . $tvShow->getID() . '</li>'; echo ' <li>Overview: ' . $tvShow->getOverview() . '</li>'; echo ' <li>Number of Seasons: ' . $tvShow->getNumSeasons() . '</li>'; echo ' <li>Seasons: <ul>'; $seasons = $tvShow->getSeasons(); foreach ($seasons as $season) {
<?php include 'tmdb-api.php'; // Insert your api key of TMDB $apikey = '8e6b3ea147a291f833ea1ead9195b3f2'; $language = 'es'; $tmdb = new TMDB($apikey, $language); // by simply giving $apikey it sets the default lang to 'en' // BUSCRA ACTOR $name = $_POST["actor"]; $persons = $tmdb->searchPerson($name); foreach ($persons as $person) { $int = (int) $person->getID(); // 2. Full Person Info echo '<div id="header"><br><br><a id="personInfo"><h3>Actor Information</h3></a>'; echo '<img src="' . $tmdb->getImageURL('w185') . $person->getProfile() . '"/>'; $person = $tmdb->getPerson($int); echo '<ul><h4><b>' . $person->getName() . '</b><ul>'; echo ' <li>ID: ' . $person->getID() . '</li>'; echo ' <li>Birthday: ' . $person->getBirthday() . '</li>'; echo ' <li>Popularity: ' . $person->getPopularity() . '</h4></li>'; echo '</ul>...'; echo '</ul></li><br><hr>'; // 3. Get the roles echo '<a id="personRoles">Movies In Chronological Order</a><br>'; $movieRoles = $person->getMovieRoles(); echo '<b>' . $person->getName() . '</b> - <b>Movies</b>: <ul></div>'; $roles = []; foreach ($movieRoles as $key => $movieRole) { $roles[$key]["personaje"] = $movieRole->getCharacter(); $roles[$key]["pelicula"] = $movieRole->getMovieTitle();
<?php require 'keys.php'; include 'tmdb-api.php'; $tmdb = new TMDB($tmdbKey); $db = new mysqli($host, $dbusername, $dbpassword, $dbname) or die("Connection Error: " . mysqli_error($db)); if (isset($_GET['query'])) { $search = $db->real_escape_string($_GET['query']); } else { http_response_code(501); die('error - no query'); } $query = "SELECT * FROM movieList WHERE MATCH (title) AGAINST ('{$search}') LIMIT 400"; if (!($result = $db->query($query))) { die(http_response_code(400)); } $imageBaseURL = 'http://image.tmdb.org/t/p/w185'; $arr = array(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $tempRow = $row; $title = $tempRow['title']; $type = $tempRow['type']; $counter = 0; $inArray = false; // Check to see if already in array for ($i = 0; $i < count($arr); ++$i) { if ($arr[$i]['title'] == $title) { if (strpos($arr[$i]['server'], $tempRow['server']) !== false) { $inArray = true; } else {
/** * Reload the content of this class.<br> * Could be used to update or complete the information. * * @param TMDB $tmdb An instance of the API handler, necesary to make the API call. */ public function reload($tmdb) { return $tmdb->getTVShow($this->getID()); }
/** * Reload the content of this class.<br> * Could be used to update or complete the information. * * @param TMDB $tmdb An instance of the API handler, necesary to make the API call. */ public function reload($tmdb) { return $tmdb->getPerson($this->getID()); }