1. Go to this page and download the library: Download duyplus/tmdbapi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
duyplus / tmdbapi example snippets
use duyplus\tmdbapi\TMDB;
// if you have a $conf array - (See LIB_ROOT/configuration/default.php as an example)
$tmdb = new TMDB($conf);
use duyplus\tmdbapi\TMDB;
// if you have no $conf it uses the default config
$tmdb = new TMDB();
//Insert your API Key of TMDB
//Necessary if you use default conf
$tmdb->setAPIKey('YOUR_API_KEY');
//Title to search for
$title = 'back to the future';
$movies = $tmdb->searchMovie($title);
// returns an array of Movie Object
foreach ($movies as $movie) {
echo $movie->getTitle() . '<br>';
}
$idMovie = 11;
$movie = $tmdb->getMovie($idMovie);
// returns a Movie Object
echo $movie->getTitle();
// Title to search for
$title = 'breaking bad';
$tvShows = $tmdb->searchTVShow($title);
foreach ($tvShows as $tvShow) {
echo $tvShow->getName() . '<br>';
}
// Name to search for
$name = 'Johnny';
$persons = $tmdb->searchPerson($name);
foreach ($persons as $person) {
echo $person->getName() . '<br>';
}
$idPerson = 85;
$person = $tmdb->getPerson($idPerson);
// returns a Person Object
echo $person->getName();
$movieRoles = $person->getMovieRoles();
foreach ($movieRoles as $movieRole) {
echo $movieRole->getCharacter() . ' in ' . $movieRole->getMovieTitle() . '<br>';
}
$tvShowRoles = $person->getTVShow();
foreach ($tvShowRoles as $tvShowRole) {
echo $tvShowRole->getCharacter() . ' in ' . $tvShowRole->getMovieName() . '<br>';
}
// Name to search for
$name = 'the hobbit';
$collections = $tmdb->searchCollection($name);
foreach ($collections as $collection) {
echo $collection->getName() . '<br>';
}