pixelead0 / tmdb_v3-PHP-API-

Wrapper in PHP for The Movie Data Base version 3
119 stars 82 forks source link

Documentation

Documentation

Join the chat at https://gitter.im/pixelead0/tmdb_v3-PHP-API-

TMDB API v3 PHP Library - wrapper to API version 3 of themoviedb.org.

For using this library maybe you should take a look at the full Documentation of this project.

@package TMDB-V3-PHP-API
@author Pixelead0 also on Github
@author Alvaro Octal also on Github
@author Deso85 also on Github
@date 02/04/2016
@version 0.5

CREDITS

Forked from a similar project by Jonas De Smet

CHANGE LOG

Requirements

How to use

View examples

Initialize the class

If you have a $conf array

<?php
    include('tmdb-api.php');

    // if you have a $conf array - (See LIB_ROOT/configuration/default.php as an example)
    $tmdb = new TMDB($conf);

?>

If you have no $conf array it uses the default conf but you need to have an API Key

<?php
    include('tmdb-api.php');

    // 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');

?>

Movies

Search a Movie

<?php
    //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>;
    }
?>

returns an array of Movie Objects.

Get a Movie

You should take a look at the Movie class Documentation and see all the info you can get from a Movie Object.

<?php
    $idMovie = 11;
    $movie = $tmdb->getMovie($idMovie);
    // returns a Movie Object
    echo $movie->getTitle();
?>

returns a Movie Object.

TV Shows

Search a TV Show

<?php
    // Title to search for
    $title = 'breaking bad';
    $tvShows = $tmdb->searchTVShow($title);
    foreach($tvShows as $tvShow){
        echo $tvShow->getName() .'<br>';
    }
?>

returns an array of TVShow Objects.

Get a TVShow

You should take a look at the TVShow class Documentation and see all the info you can get from a TVShow Object.

<?php
    $idTVShow = 1396;
    $tvShow = $tmdb->getTVShow($idTVShow);
    // returns a TVShow Object
    echo $tvShow->getName();
?>

returns a TVShow Object.

Get a TVShow's Season

You should take a look at the Season class Documentation and see all the info you can get from a Season Object.

<?php
    $idTVShow = 1396;
    $numSeason = 2;
    $season = $tmdb->getSeason($idTVShow, $numSeason);
    // returns a Season Object
    echo $season->getName();
?>

returns a Season Object.

Get a TVShow's Episode

You should take a look at the Episode class Documentation and see all the info you can get from a Episode Object.

<?php
    $idTVShow = 1396;
    $numSeason = 2;
    $numEpisode = 8;
    $episode = $tmdb->getEpisode($idTVShow, $numSeason, $numEpisode);
    // returns a Episode Object
    echo $episode->getName();
?>

returns a Episode Object.

Persons

Search a Person

<?php
    // Name to search for
    $name = 'Johnny';
    $persons = $tmdb->searchPerson($name);
    foreach($persons as $person){
        echo $person->getName() .'<br>';
    }
?>

returns an array of Person Objects.

Get a Person

You should take a look at the Person class Documentation and see all the info you can get from a Person Object.

<?php
    $idPerson = 85;
    $person = $tmdb->getPerson($idPerson);
    // returns a Person Object
    echo $person->getName();
?>

returns a Person Object.

Get Person's Roles

You should take a look at the Role class Documentation and see all the info you can get from a Role Object.

<?php
    $movieRoles = $person->getMovieRoles();
    foreach($movieRoles as $movieRole){
        echo $movieRole->getCharacter() .' in '. $movieRole->getMovieTitle() .'<br>';
    }
?>

returns an array of MovieRole Objects.

<?php
    $tvShowRoles = $person->getTVShow();
    foreach($tvShowRoles as $tvShowRole){
        echo $tvShowRole->getCharacter() .' in '. $tvShowRole->getMovieName() .'<br>';
    }
?>

returns an array of TVShowRole Objects.

Collections

Search a Collection

<?php
    // Name to search for
    $name = 'the hobbit';
    $collections = $tmdb->searchCollection($name);
    foreach($collections as $collection){
        echo $collection->getName() .'<br>';
    }
?>

returns an array of Collection Objects.

Get a Collection

You should take a look at the Collection class Documentation and see all the info you can get from a Collection Object.

<?php
    $idCollection = 121938;
    $collection = $tmdb->getCollection($idCollection);
    // returns a Collection Object
    echo $collection->getName();
?>

returns a Collection Object.

Companies

Search a Company

<?php
    // Name to search for
    $name = 'Sony';
    $companies = $tmdb->searchCompany($name);
    foreach($companies as $company){
        echo $company->getName() .'<br>';
    }
?>

returns an array of Company Objects.

Get a Company

You should take a look at the Company class Documentation and see all the info you can get from a Company Object.

<?php
    $idCompany = 34;
    $company = $tmdb->getCompany($idCompany);
    // returns a Company Object
    echo $company->getName();
?>

returns a Company Object.

Issues/Bugs

Bugs are expected, this is still under development, you can report them.

TODO List