PHP code example of vfalies / tmdb

1. Go to this page and download the library: Download vfalies/tmdb 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/ */

    

vfalies / tmdb example snippets




facTmdb\Factory;
use VfacTmdb\Search;
use VfacTmdb\Item;

// Initialize Wrapper
$tmdb = Factory::create()->getTmdb('your_api_key');

// Search a movie
$search    = new Search($tmdb);
$responses = $search->movie('star wars');

// Get all results
foreach ($responses as $response)
{
    echo $response->getTitle();
}

// Get movie information
$item  = new Item($tmdb);
$infos = $item->getMovie(11, array('language' => 'fr-FR'));

echo $infos->getTitle();


VfacTmdb\Factory;

$tmdb = Factory::create()->getTmdb('your_api_key');

$container['tmdb'] = function ($c) {
    $api_key = $c->get('settings')['tmdb']['api_key'];
    $tmdb = new \vfalies\tmdb\Tmdb($api_key, $c->logger);
}

return [
    'settings' = [
        'tmdb' = [
            'api_key' = 'your_api_key';
        ]
    ]
];


VfacTmdb\Tmdb;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('default', [new StreamHandler('php://stdout')])

$tmdb = Tmdb('your_api_key', $logger);

$search    = new Search($tmdb);
$responses = $search->movie('star wars');

$item  = new Item($tmdb);
$movie = $item->getMovie($movie_id);

echo $movie->getTitle();

$search    = new Search($tmdb);
$responses = $search->tvshow('game of thrones');

$item   = new Item($tmdb);
$tvshow = $item->getTVShow($tvshow_id);

echo $tvshow->getTitle();

$item     = new Item($tmdb);
$tvseason = $item->getTVSeason($tvshow_id, $season_number);

echo $tvseason->getName();

$item      = new Item($tmdb);
$tvepisode = $item->getTVEpisode($tvshow_id, $season_number, $episode_number);

echo $tvepisode->getName();

$search    = new Search($tmdb);
$responses = $search->collection('alien');

$item       = new Item($tmdb);
$collection = $item->getCollection($collection_id);

echo $collection->getName();

$search    = new Search($tmdb);
$responses = $search->people('alec baldwin');

$item   = new Item($tmdb);
$people = $item->getPeople($people_id);

echo $people->getName();

$search    = new Search($tmdb);
$responses = $search->company('lucasfilms');

$item   = new Item($tmdb);
$company = $item->getCompany($company_id);

echo $company->getName();

$find = new Find($tmdb);
$responses = $find->imdb('tt0076759');

$movies = $responses->getMovies();
$title  = $movies->current()->getTitle();

$tmdb = Factory::create()->getTmdb('your_api_key');

$Auth = new Auth($tmdb);
echo $Auth->getRequestToken();

$tmdb = Factory::create()->getTmdb('your_api_key');

$Auth = new Auth($tmdb);
$Auth->connect($_POST['request_token']);

$tmdb = Factory::create()->getTmdb('your_api_key');

$Auth = new Auth($tmdb);
$Auth->connect($_POST['request_token'], 'http://your_url');

$tmdb = Factory::create()->getTmdb('62dfe9839b8937e595e325a4144702ad');

$Auth = new Auth($tmdb);
echo $Auth->createSession($_POST['request_token']);

$media = new Media($tmdb);
$url = $media->getPosterUrl('/AbJBXaVPrdXROwb8KmgWUPU2XJX.jpg');