1. Go to this page and download the library: Download mediaflux/php-tmdb-api 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/ */
mediaflux / php-tmdb-api example snippets
$token = new \Tmdb\ApiToken('your_tmdb_api_key_here');
$client = new \Tmdb\Client($token);
$client = new \Tmdb\Client($token, ['secure' => false]);
$repository = new \Tmdb\Repository\MovieRepository($client);
$movie = $repository->load(87421);
echo $movie->getTitle();
$repository = new \Tmdb\Repository\MovieRepository($client);
$topRated = $repository->getTopRated(array('page' => 3));
// or
$popular = $repository->getPopular();
$configRepository = new \Tmdb\Repository\ConfigurationRepository($client);
$config = $configRepository->load();
$imageHelper = new \Tmdb\Helper\ImageHelper($config);
echo $imageHelper->getHtml($image, 'w154', 154, 80);
$plugin = new \Tmdb\HttpClient\Plugin\LanguageFilterPlugin('nl');
$plugin = new \Tmdb\HttpClient\Plugin\AdultFilterPlugin(true);
foreach($movie->getImages()->filter(
function($key, $value){
if ($value instanceof \Tmdb\Model\Image\PosterImage) { return true; }
}
) as $image) {
// do something with all poster images
}