├── .github └── workflows │ └── documentation.yml ├── .gitignore ├── README.markdown ├── apigen.neon ├── composer.json ├── composer.lock ├── configuration ├── all.php └── default.php ├── controller └── classes │ ├── config │ ├── APIConfiguration.php │ └── Configuration.php │ ├── data │ ├── ApiBaseObject.php │ ├── Collection.php │ ├── Company.php │ ├── Episode.php │ ├── Genre.php │ ├── Movie.php │ ├── Person.php │ ├── Review.php │ ├── Role.php │ ├── Season.php │ └── TVShow.php │ ├── jobs │ ├── MovieJob.php │ └── TVShowJob.php │ └── roles │ ├── MovieRole.php │ └── TVShowRole.php ├── examples ├── .htaccess ├── genres │ ├── movieGenres.php │ └── tvShowGenres.php ├── index.php ├── movies │ ├── featuredMovies.php │ ├── findMovie.php │ ├── infoCollection.php │ ├── infoCompany.php │ ├── infoMovie.php │ ├── searchCollection.php │ ├── searchCompany.php │ ├── searchMovie.php │ └── searchMovieByGenre.php ├── people │ ├── featuredPersons.php │ ├── findPerson.php │ ├── infoPerson.php │ ├── infoRoles.php │ └── searchPerson.php ├── search │ └── multiSearch.php └── tvshows │ ├── featuredTVShows.php │ ├── findTVShow.php │ ├── infoEpisode.php │ ├── infoSeason.php │ ├── infoTVShow.php │ └── searchTVShow.php └── tmdb-api.php /.github/workflows/documentation.yml: -------------------------------------------------------------------------------- 1 | name: Documentation 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - uses: shivammathur/setup-php@v2 18 | with: 19 | php-version: '7.4' 20 | 21 | - name: Validate composer.json and composer.lock 22 | run: composer validate 23 | 24 | - name: Cache Composer packages 25 | id: composer-cache 26 | uses: actions/cache@v2 27 | with: 28 | path: vendor 29 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 30 | restore-keys: | 31 | ${{ runner.os }}-php- 32 | 33 | - name: Install dependencies 34 | if: steps.composer-cache.outputs.cache-hit != 'true' 35 | run: composer update --no-progress --no-suggest 36 | 37 | - name: Generate documentation 38 | run: composer run-script documentation 39 | 40 | - name: Publish documentation 41 | uses: peaceiris/actions-gh-pages@v3 42 | with: 43 | github_token: ${{ secrets.GITHUB_TOKEN }} 44 | publish_dir: ./docs 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .project 3 | /vendor/ 4 | .idea 5 | docs 6 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | ## Documentation ## 2 | 3 | [![Documentation](https://github.com/pixelead0/tmdb_v3-PHP-API-/workflows/Documentation/badge.svg?event=push)](https://pixelead0.github.io/tmdb_v3-PHP-API-/index.html) 4 | 5 | [![Join the chat at https://gitter.im/pixelead0/tmdb_v3-PHP-API-](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pixelead0/tmdb_v3-PHP-API-?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 6 | 7 | TMDB API v3 PHP Library - wrapper to [API version 3](https://developers.themoviedb.org/3/) of [themoviedb.org](http://themoviedb.org). 8 | 9 | For using this library maybe you should take a look at the full [Documentation](http://pixelead0.github.io/tmdb_v3-PHP-API-/index.html) of this project. 10 | 11 | @package TMDB-V3-PHP-API
12 | @author [Pixelead0](https://twitter.com/pixelead0) also on [Github](https://github.com/pixelead0)
13 | @author [Alvaro Octal](https://twitter.com/Alvaro_Octal) also on [Github](https://github.com/Alvaroctal)
14 | @author [Deso85](https://twitter.com/Cizero) also on [Github](https://github.com/deso85)
15 | @date 02/04/2016
16 | @version 0.5
17 | 18 | ## CREDITS ### 19 | 20 | Forked from a similar [project](https://github.com/glamorous/TMDb-PHP-API) by [Jonas De Smet](https://github.com/glamorous) 21 | 22 | ### CHANGE LOG ### 23 | * [18/06/2017] v0.6 24 | - Implemented function for multiSearch 25 | - Added example for multiSearch 26 | - Fixed examples 27 | 28 | * [02/04/2016] v0.5 29 | - Made a class for configuration to load external configs 30 | - Updated functions list 31 | - Changed a few functions to use config object 32 | - Changed package structure of the project 33 | 34 | * [01/04/2016] v0.4 35 | - Added config file 36 | - Some code changes to use config file 37 | - Some formal corrections inside comments 38 | - (Hopefully) Corrected Versioning 39 | 40 | * [17/01/2015] v0.3 - Upgraded by 41 | - Upgrade by [/Alvaroctal/TMDB-PHP-API](https://github.com/Alvaroctal/TMDB-PHP-API). 42 | - Some modifications and dedicated classes added. 43 | 44 | * [07/11/2012] v0.2 45 | - Fixed issue #2 (Object created in class php file) 46 | - Added functions latestMovie, nowPlayingMovies (thank's to steffmeister) 47 | 48 | * [12/02/2012] v0.1 49 | - This is the first version of the class without inline documentation or testing 50 | - Forked from [glamorous/TMDb-PHP-API](https://github.com/glamorous/TMDb-PHP-API) 51 | 52 | ### Requirements ### 53 | - PHP 5.2.x or higher 54 | - cURL 55 | - TMDB API-key 56 | 57 | ## How to use ## 58 | View examples 59 | 60 | ### Initialize the class ### 61 | If you have a $conf array 62 | 63 | 70 | 71 | If you have no $conf array it uses the default conf but you need to have an API Key 72 | 73 | setAPIKey('YOUR_API_KEY'); 82 | 83 | ?> 84 | ## Movies ## 85 | ### Search a Movie ### 86 | searchMovie($title); 90 | // returns an array of Movie Object 91 | foreach($movies as $movie){ 92 | echo $movie->getTitle() .'
; 93 | } 94 | ?> 95 | returns an array of [Movie](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Movie.html) Objects. 96 | ### Get a Movie ### 97 | You should take a look at the Movie class [Documentation](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Movie.html) and see all the info you can get from a Movie Object. 98 | 99 | getMovie($idMovie); 102 | // returns a Movie Object 103 | echo $movie->getTitle(); 104 | ?> 105 | returns a [Movie](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Movie.html) Object. 106 | ## TV Shows ## 107 | ### Search a TV Show ### 108 | searchTVShow($title); 112 | foreach($tvShows as $tvShow){ 113 | echo $tvShow->getName() .'
'; 114 | } 115 | ?> 116 | returns an array of [TVShow](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-TVShow.html) Objects. 117 | ### Get a TVShow ### 118 | You should take a look at the TVShow class [Documentation](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-TVShow.html) and see all the info you can get from a TVShow Object. 119 | 120 | getTVShow($idTVShow); 123 | // returns a TVShow Object 124 | echo $tvShow->getName(); 125 | ?> 126 | returns a [TVShow](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-TVShow.html) Object. 127 | ### Get a TVShow's Season ### 128 | You should take a look at the Season class [Documentation](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Season.html) and see all the info you can get from a Season Object. 129 | 130 | getSeason($idTVShow, $numSeason); 134 | // returns a Season Object 135 | echo $season->getName(); 136 | ?> 137 | returns a [Season](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Season.html) Object. 138 | ### Get a TVShow's Episode ### 139 | You should take a look at the Episode class [Documentation](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Episode.html) and see all the info you can get from a Episode Object. 140 | 141 | getEpisode($idTVShow, $numSeason, $numEpisode); 146 | // returns a Episode Object 147 | echo $episode->getName(); 148 | ?> 149 | returns a [Episode](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Episode.html) Object. 150 | ## Persons ## 151 | ### Search a Person ### 152 | searchPerson($name); 156 | foreach($persons as $person){ 157 | echo $person->getName() .'
'; 158 | } 159 | ?> 160 | returns an array of [Person](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Person.html) Objects. 161 | ### Get a Person ### 162 | You should take a look at the Person class [Documentation](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Person.html) and see all the info you can get from a Person Object. 163 | 164 | getPerson($idPerson); 167 | // returns a Person Object 168 | echo $person->getName(); 169 | ?> 170 | returns a [Person](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Person.html) Object. 171 | ### Get Person's Roles ### 172 | You should take a look at the Role class [Documentation](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Role.html) and see all the info you can get from a Role Object. 173 | 174 | getMovieRoles(); 176 | foreach($movieRoles as $movieRole){ 177 | echo $movieRole->getCharacter() .' in '. $movieRole->getMovieTitle() .'
'; 178 | } 179 | ?> 180 | returns an array of [MovieRole](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-MovieRole.html) Objects. 181 | 182 | getTVShow(); 184 | foreach($tvShowRoles as $tvShowRole){ 185 | echo $tvShowRole->getCharacter() .' in '. $tvShowRole->getMovieName() .'
'; 186 | } 187 | ?> 188 | returns an array of [TVShowRole](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-TVShowRole.html) Objects. 189 | ## Collections ## 190 | ### Search a Collection ### 191 | 192 | searchCollection($name); 196 | foreach($collections as $collection){ 197 | echo $collection->getName() .'
'; 198 | } 199 | ?> 200 | returns an array of [Collection](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Collection.html) Objects. 201 | ### Get a Collection ### 202 | You should take a look at the Collection class [Documentation](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Collection.html) and see all the info you can get from a Collection Object. 203 | 204 | getCollection($idCollection); 207 | // returns a Collection Object 208 | echo $collection->getName(); 209 | ?> 210 | returns a [Collection](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Collection.html) Object. 211 | ## Companies ## 212 | ### Search a Company ### 213 | 214 | searchCompany($name); 218 | foreach($companies as $company){ 219 | echo $company->getName() .'
'; 220 | } 221 | ?> 222 | returns an array of [Company](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Company.html) Objects. 223 | ### Get a Company ### 224 | You should take a look at the Company class [Documentation](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Company.html) and see all the info you can get from a Company Object. 225 | 226 | getCompany($idCompany); 229 | // returns a Company Object 230 | echo $company->getName(); 231 | ?> 232 | returns a [Company](http://pixelead0.github.io/tmdb_v3-PHP-API-/class-Company.html) Object. 233 | ## Issues/Bugs ## 234 | Bugs are expected, this is still under development, you can [report](https://github.com/Alvaroctal/TMDB-PHP-API/issues) them. 235 | 236 | ### TODO List ### 237 | - Empty :D, you can [propose](https://github.com/pixelead0/tmdb_v3-PHP-API-/issues) new functionalities. 238 | -------------------------------------------------------------------------------- /apigen.neon: -------------------------------------------------------------------------------- 1 | # list of scanned file extensions (e.g. php5, phpt...) 2 | extensions: [php] 3 | 4 | # directories and files matching this file mask will not be parsed 5 | exclude: 6 | - examples/ 7 | 8 | # similar to above, but this files will be included in class tree 9 | skipDocPath: 10 | - *Component\Console 11 | 12 | # character set of source files; if you use only one across your files, we recommend you name it 13 | charset: [UTF-8] 14 | 15 | # title of generated documentation 16 | title: TMDB PHP API Documentation 17 | 18 | # base url used for sitemap (useful for public doc) 19 | baseUrl: http://api.apigen.org 20 | 21 | # custom search engine id, will be used by search box 22 | googleCseId: 011549293477758430224 23 | 24 | # Google Analytics tracking code 25 | googleAnalytics: UA-35236-5 26 | 27 | # choose ApiGen template theme 28 | templateTheme: bootstrap # or: default 29 | 30 | # the way elements are grouped in menu 31 | groups: auto # also: namespace, packages, none; auto will detect namespace first, than packages 32 | 33 | # access levels of included method and properties 34 | accessLevels: [public, protected, private] # also [private] 35 | 36 | # include elements marked as @internal/{@internal} 37 | internal: true 38 | 39 | # generate documentation for PHP internal classes 40 | php: true 41 | 42 | # generate highlighted source code for elements 43 | sourceCode: true 44 | 45 | # generate tree view of classes, interfaces, traits and exceptions 46 | tree: false 47 | 48 | # generate documentation for deprecated elements 49 | deprecated: true 50 | 51 | # generate list of tasks with @todo annotation 52 | todo: false 53 | 54 | # add link to ZIP archive of documentation 55 | download: false -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "buibr/tmdbapi", 3 | "description": "PHP wrapper for The Movie Data Base API version 3", 4 | "keywords": [ 5 | "markdown", 6 | "gfm", 7 | "markdown-extra", 8 | "fast", 9 | "extensible" 10 | ], 11 | "type": "library", 12 | "license": "MIT", 13 | "scripts": { 14 | "documentation": "php vendor/bin/apigen generate controller --destination docs" 15 | }, 16 | "authors": [ 17 | { 18 | "name": "Adan GQ", 19 | "email": "adan@dont.know", 20 | "role": "Developer" 21 | }, 22 | { 23 | "name": "Burhan Ibrahimi", 24 | "email": "burhan@wflux.pro", 25 | "role": "Developer" 26 | } 27 | ], 28 | "require": { 29 | "php": ">=5.5.0" 30 | }, 31 | "minimum-stability": "dev", 32 | "autoload": { 33 | "psr-4": { 34 | "buibr\\tmdbapi\\": "" 35 | } 36 | }, 37 | "require-dev": { 38 | "apigen/apigen": "dev-master", 39 | "roave/better-reflection": "dev-master#1efdfe5" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /configuration/all.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /configuration/default.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /controller/classes/config/APIConfiguration.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 20/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class APIConfiguration { 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $_data; 20 | 21 | /** 22 | * Construct Class 23 | * 24 | * @param array $data An array with the data of a Configuration 25 | */ 26 | public function __construct($data) { 27 | $this->_data = $data; 28 | } 29 | 30 | //------------------------------------------------------------------------------ 31 | // Get Variables 32 | //------------------------------------------------------------------------------ 33 | 34 | /** 35 | * Get the Configuration's base URL for images 36 | * 37 | * @return string 38 | */ 39 | public function getImageBaseURL() { 40 | return $this->_data['images']['base_url']; 41 | } 42 | 43 | /** 44 | * Get the Configuration's secure base URL for images 45 | * 46 | * @return string 47 | */ 48 | public function getSecureImageBaseURL() { 49 | return $this->_data['images']['secure_base_url']; 50 | } 51 | 52 | /** 53 | * Get the Configuration's list of sizes for backdrops 54 | * 55 | * @return string[] 56 | */ 57 | public function getBackdropSizes() { 58 | return $this->_data['images']['backdrop_sizes']; 59 | } 60 | 61 | /** 62 | * Get the Configuration's list of sizes for logos 63 | * 64 | * @return string[] 65 | */ 66 | public function getLogoSizes() { 67 | return $this->_data['images']['logo_sizes']; 68 | } 69 | 70 | /** 71 | * Get the Configuration's list of sizes for posters 72 | * 73 | * @return string[] 74 | */ 75 | public function getPosterSizes() { 76 | return $this->_data['images']['poster_sizes']; 77 | } 78 | 79 | /** 80 | * Get the Configuration's list of sizes for profiles 81 | * 82 | * @return string[] 83 | */ 84 | public function getProfileSizes() { 85 | return $this->_data['images']['profile_sizes']; 86 | } 87 | 88 | /** 89 | * Get the Configuration's list of sizes for stills 90 | * 91 | * @return string[] 92 | */ 93 | public function getStillSizes() { 94 | return $this->_data['images']['still_sizes']; 95 | } 96 | 97 | /** 98 | * Get Generic.
99 | * Get a item of the array, you should not get used to use this, better use specific get's. 100 | * 101 | * @param string $item The item of the $data array you want 102 | * @return array 103 | */ 104 | public function get($item = '') { 105 | return (empty($item)) ? $this->_data : $this->_data[$item]; 106 | } 107 | 108 | //------------------------------------------------------------------------------ 109 | // Export 110 | //------------------------------------------------------------------------------ 111 | 112 | /** 113 | * Get the JSON representation of the Configuration 114 | * 115 | * @return string 116 | */ 117 | public function getJSON() { 118 | return json_encode($this->_data, JSON_PRETTY_PRINT); 119 | } 120 | } 121 | ?> -------------------------------------------------------------------------------- /controller/classes/config/Configuration.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 02/04/2016 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class Configuration { 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $apikey = ''; 20 | private $lang = 'en'; 21 | private $timezone = 'Europe/London'; 22 | private $adult = false; 23 | private $debug = false; 24 | private $appender; 25 | 26 | //------------------------------------------------------------------------------ 27 | // Constructor 28 | //------------------------------------------------------------------------------ 29 | 30 | /** 31 | * Construct Class 32 | * 33 | * @param array $cnf An array with the configuration data 34 | */ 35 | public function __construct($cnf) { 36 | // Check if config is given and use default if not 37 | // Note: There is no API Key inside the default conf 38 | if(!isset($cnf)) { 39 | require_once( dirname(__FILE__) . "/../../../configuration/default.php"); 40 | } 41 | 42 | $this->setAPIKey($cnf['apikey']); 43 | $this->setLang($cnf['lang']); 44 | $this->setTimeZone('timezone'); 45 | $this->setAdult($cnf['adult']); 46 | $this->setDebug($cnf['debug']); 47 | 48 | foreach($cnf['appender'] as $type => $appender) { 49 | $this->setAppender($appender, $type); 50 | } 51 | } 52 | 53 | //------------------------------------------------------------------------------ 54 | // Set Variables 55 | //------------------------------------------------------------------------------ 56 | 57 | /** 58 | * Set the API Key 59 | * 60 | * @param string $apikey 61 | */ 62 | public function setAPIKey($apikey){ 63 | $this->apikey = $apikey; 64 | } 65 | 66 | /** 67 | * Set the language code 68 | * 69 | * @param string $lang 70 | */ 71 | public function setLang($lang){ 72 | $this->lang = $lang; 73 | } 74 | 75 | /** 76 | * Set the timezone 77 | * 78 | * @param string $timezone 79 | */ 80 | public function setTimeZone($timezone){ 81 | $this->timezone = $timezone; 82 | } 83 | 84 | /** 85 | * Set the adult flag 86 | * 87 | * @param boolean $adult 88 | */ 89 | public function setAdult($adult){ 90 | $this->adult = $adult; 91 | } 92 | 93 | /** 94 | * Set the debug flag 95 | * 96 | * @param boolean $debug 97 | */ 98 | public function setDebug($debug){ 99 | $this->debug = $debug; 100 | } 101 | 102 | /** 103 | * Set an appender for a special type 104 | * 105 | * @param array $appender 106 | * @param string $type 107 | */ 108 | public function setAppender($appender, $type){ 109 | $this->appender[$type] = $appender; 110 | } 111 | 112 | //------------------------------------------------------------------------------ 113 | // Get Variables 114 | //------------------------------------------------------------------------------ 115 | 116 | /** 117 | * Get the API Key 118 | * 119 | * @return string 120 | */ 121 | public function getAPIKey(){ 122 | return $this->apikey; 123 | } 124 | 125 | /** 126 | * Get the language code 127 | * 128 | * @return string 129 | */ 130 | public function getLang(){ 131 | return $this->lang; 132 | } 133 | 134 | /** 135 | * Get the timezone 136 | * 137 | * @return string 138 | */ 139 | public function getTimeZone(){ 140 | return $this->timezone; 141 | } 142 | 143 | /** 144 | * Get the adult string 145 | * 146 | * @return string 147 | */ 148 | public function getAdult(){ 149 | return ($this->adult) ? 'true' : 'false'; 150 | } 151 | 152 | /** 153 | * Get the debug flag 154 | * 155 | * @return boolean 156 | */ 157 | public function getDebug(){ 158 | return $this->debug; 159 | } 160 | 161 | /** 162 | * Get the appender array for a type 163 | * 164 | * @return array 165 | */ 166 | public function getAppender($type){ 167 | return $this->appender[$type]; 168 | } 169 | } 170 | 171 | ?> -------------------------------------------------------------------------------- /controller/classes/data/ApiBaseObject.php: -------------------------------------------------------------------------------- 1 | Twitter 8 | * @version 0.1 9 | * @date 14/09/2017 10 | * @link https://github.com/pixelead0/tmdb_v3-PHP-API- 11 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 12 | */ 13 | class ApiBaseObject 14 | { 15 | //------------------------------------------------------------------------------ 16 | // Class Constants 17 | //------------------------------------------------------------------------------ 18 | 19 | const MEDIA_TYPE_MOVIE = 'movie'; 20 | const CREDITS_TYPE_CAST = 'cast'; 21 | const CREDITS_TYPE_CREW = 'crew'; 22 | const MEDIA_TYPE_TV = 'tv'; 23 | 24 | //------------------------------------------------------------------------------ 25 | // Class Variables 26 | //------------------------------------------------------------------------------ 27 | 28 | protected $_data; 29 | 30 | /** 31 | * Construct Class 32 | * 33 | * @param array $data An array with the data of the ApiObject 34 | */ 35 | public function __construct($data) { 36 | $this->_data = $data; 37 | } 38 | 39 | /** 40 | * Get the ApiObject id 41 | * 42 | * @return int 43 | */ 44 | public function getID() { 45 | return $this->_data['id']; 46 | } 47 | 48 | /** 49 | * Get the ApiObject Poster 50 | * 51 | * @return string 52 | */ 53 | public function getPoster() { 54 | return $this->_data['poster_path']; 55 | } 56 | 57 | /** 58 | * Get the ApiObjects vote average 59 | * 60 | * @return int 61 | */ 62 | public function getVoteAverage() { 63 | return $this->_data['vote_average']; 64 | } 65 | 66 | /** 67 | * Get the ApiObjects vote count 68 | * 69 | * @return int 70 | */ 71 | public function getVoteCount() { 72 | return $this->_data['vote_count']; 73 | } 74 | 75 | /** 76 | * Get the ApiObjects Cast 77 | * @return array of Person 78 | */ 79 | public function getCast(){ 80 | return $this->getCredits(self::CREDITS_TYPE_CAST); 81 | } 82 | 83 | /** 84 | * Get the Cast or the Crew of an ApiObject 85 | * @param string $key 86 | * @return array of Person 87 | */ 88 | protected function getCredits($key){ 89 | $persons = []; 90 | 91 | foreach ($this->_data['credits'][$key] as $data) { 92 | $persons[] = new Person($data); 93 | } 94 | 95 | return $persons; 96 | } 97 | 98 | /** 99 | * Get the ApiObject's genres 100 | * 101 | * @return Genre[] 102 | */ 103 | public function getGenres() { 104 | $genres = array(); 105 | 106 | foreach ($this->_data['genres'] as $data) { 107 | $genres[] = new Genre($data); 108 | } 109 | 110 | return $genres; 111 | } 112 | 113 | /** 114 | * Get the ApiObject crew 115 | * @return array of Person 116 | */ 117 | public function getCrew(){ 118 | return $this->getCredits(self::CREDITS_TYPE_CREW); 119 | } 120 | 121 | /** 122 | * Get Generic.
123 | * Get a item of the array, you should not get used to use this, better use specific get's. 124 | * 125 | * @param string $item The item of the $data array you want 126 | * @return array 127 | */ 128 | public function get($item = ''){ 129 | 130 | if(empty($item)){ 131 | return $this->_data; 132 | } 133 | 134 | if(array_key_exists($item, $this->_data)){ 135 | return $this->_data[$item]; 136 | } 137 | 138 | return null; 139 | } 140 | 141 | /** 142 | * Add a magical call method to allow non defined get methods like $tmdb->getNextEpisodeToAir() 143 | * 144 | * @param $property 145 | * @param array $arguments 146 | * 147 | * @return array|null 148 | * @throws ErrorException 149 | */ 150 | public function __call($property, array $arguments) 151 | { 152 | if (\strpos($property, 'get') !== 0) { 153 | throw new \ErrorException(\sprintf('Call to undefined method: %s::%s', __CLASS__, $property)); 154 | } 155 | 156 | $property = \preg_replace_callback( 157 | '%[A-Z]+%', 158 | static function($match) {return '_'. \strtolower($match[0]);}, 159 | $property 160 | ); 161 | 162 | $property = \str_replace('get_', '', $property); 163 | 164 | return $this->get($property); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /controller/classes/data/Collection.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 11/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class Collection { 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $_data; 20 | 21 | /** 22 | * Construct Class 23 | * 24 | * @param array $data An array with the data of a Collection 25 | */ 26 | public function __construct($data) { 27 | $this->_data = $data; 28 | } 29 | 30 | //------------------------------------------------------------------------------ 31 | // Get Variables 32 | //------------------------------------------------------------------------------ 33 | 34 | /** 35 | * Get the Collection's name 36 | * 37 | * @return string 38 | */ 39 | public function getName() { 40 | return $this->_data['name']; 41 | } 42 | 43 | /** 44 | * Get the Collection's id 45 | * 46 | * @return int 47 | */ 48 | public function getID() { 49 | return $this->_data['id']; 50 | } 51 | 52 | /** 53 | * Get the Collection's overview 54 | * 55 | * @return string 56 | */ 57 | public function getOverview() { 58 | return $this->_data['overview']; 59 | } 60 | 61 | /** 62 | * Get the Collection's poster 63 | * 64 | * @return string 65 | */ 66 | public function getPoster() { 67 | return $this->_data['poster_path']; 68 | } 69 | 70 | /** 71 | * Get the Collection's backdrop 72 | * 73 | * @return string 74 | */ 75 | public function getBackdrop() { 76 | return $this->_data['backdrop_path']; 77 | } 78 | 79 | /** 80 | * Get the Collection's Movies 81 | * 82 | * @return Movie[] 83 | */ 84 | public function getMovies() { 85 | $movies = array(); 86 | 87 | foreach($this->_data['parts'] as $data){ 88 | $movies[] = new Movie($data); 89 | } 90 | 91 | return $movies; 92 | } 93 | 94 | /** 95 | * Get Generic.
96 | * Get a item of the array, you should not get used to use this, better use specific get's. 97 | * 98 | * @param string $item The item of the $data array you want 99 | * @return array 100 | */ 101 | public function get($item = '') { 102 | return (empty($item)) ? $this->_data : $this->_data[$item]; 103 | } 104 | } 105 | ?> -------------------------------------------------------------------------------- /controller/classes/data/Company.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 11/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class Company { 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $_data; 20 | 21 | /** 22 | * Construct Class 23 | * 24 | * @param array $data An array with the data of a Company 25 | */ 26 | public function __construct($data) { 27 | $this->_data = $data; 28 | } 29 | 30 | //------------------------------------------------------------------------------ 31 | // Get Variables 32 | //------------------------------------------------------------------------------ 33 | 34 | /** 35 | * Get the Company's name 36 | * 37 | * @return string 38 | */ 39 | public function getName() { 40 | return $this->_data['name']; 41 | } 42 | 43 | /** 44 | * Get the Company's id 45 | * 46 | * @return int 47 | */ 48 | public function getID() { 49 | return $this->_data['id']; 50 | } 51 | 52 | /** 53 | * Get the Company's description 54 | * 55 | * @return string 56 | */ 57 | public function getDescription() { 58 | return $this->_data['description']; 59 | } 60 | 61 | /** 62 | * Get the Company's headquearters 63 | * 64 | * @return string 65 | */ 66 | public function getHeadquarters() { 67 | return $this->_data['headquarters']; 68 | } 69 | 70 | /** 71 | * Get the Company's homepage 72 | * 73 | * @return string 74 | */ 75 | public function getHomepage() { 76 | return $this->_data['homepage']; 77 | } 78 | 79 | /** 80 | * Get the Company's logo 81 | * 82 | * @return string 83 | */ 84 | public function getLogo() { 85 | return $this->_data['logo_path']; 86 | } 87 | 88 | /** 89 | * Get the Company's parent company id 90 | * 91 | * @return int 92 | */ 93 | public function getParentCompanyID() { 94 | return $this->_data['parent_company']; 95 | } 96 | 97 | /** 98 | * Get the Company's Movies 99 | * 100 | * @return Movie[] 101 | */ 102 | public function getMovies() { 103 | $movies = array(); 104 | 105 | foreach($this->_data['movies']['results'] as $data){ 106 | $movies[] = new Movie($data); 107 | } 108 | 109 | return $movies; 110 | } 111 | 112 | /** 113 | * Get Generic.
114 | * Get a item of the array, you should not get used to use this, better use specific get's. 115 | * 116 | * @param string $item The item of the $data array you want 117 | * @return array 118 | */ 119 | public function get($item = '') { 120 | return (empty($item)) ? $this->_data : $this->_data[$item]; 121 | } 122 | 123 | //------------------------------------------------------------------------------ 124 | // Export 125 | //------------------------------------------------------------------------------ 126 | 127 | /** 128 | * Get the JSON representation of the Movie 129 | * 130 | * @return string 131 | */ 132 | public function getJSON() { 133 | return json_encode($this->_data, JSON_PRETTY_PRINT); 134 | } 135 | } 136 | ?> -------------------------------------------------------------------------------- /controller/classes/data/Episode.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 11/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class Episode{ 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $_data; 20 | 21 | /** 22 | * Construct Class 23 | * 24 | * @param array $data An array with the data of the Episode 25 | */ 26 | public function __construct($data, $idTVShow = 0) { 27 | $this->_data = $data; 28 | $this->_data['tvshow_id'] = $idTVShow; 29 | } 30 | 31 | //------------------------------------------------------------------------------ 32 | // Get Variables 33 | //------------------------------------------------------------------------------ 34 | 35 | /** 36 | * Get the episode's id 37 | * 38 | * @return int 39 | */ 40 | public function getID() { 41 | return $this->_data['id']; 42 | } 43 | 44 | /** 45 | * Get the Episode's name 46 | * 47 | * @return string 48 | */ 49 | public function getName() { 50 | return $this->_data['name']; 51 | } 52 | 53 | /** 54 | * Get the Season's TVShow id 55 | * 56 | * @return int 57 | */ 58 | public function getTVShowID() { 59 | return $this->_data['tvshow_id']; 60 | } 61 | 62 | /** 63 | * Get the Season's number 64 | * 65 | * @return int 66 | */ 67 | public function getSeasonNumber() { 68 | return $this->_data['season_number']; 69 | } 70 | 71 | /** 72 | * Get the Episode's number 73 | * 74 | * @return string 75 | */ 76 | public function getEpisodeNumber() { 77 | return $this->_data['episode_number']; 78 | } 79 | 80 | /** 81 | * Get the Episode's Overview 82 | * 83 | * @return string 84 | */ 85 | public function getOverview() { 86 | return $this->_data['overview']; 87 | } 88 | 89 | /** 90 | * Get the Seasons's Still 91 | * 92 | * @return string 93 | */ 94 | public function getStill() { 95 | return $this->_data['still_path']; 96 | } 97 | 98 | /** 99 | * Get the Season's AirDate 100 | * 101 | * @return string 102 | */ 103 | public function getAirDate() { 104 | return $this->_data['air_date']; 105 | } 106 | 107 | /** 108 | * Get the Episode's vote average 109 | * 110 | * @return int 111 | */ 112 | public function getVoteAverage() { 113 | return $this->_data['vote_average']; 114 | } 115 | 116 | /** 117 | * Get the Episode's vote count 118 | * 119 | * @return int 120 | */ 121 | public function getVoteCount() { 122 | return $this->_data['vote_count']; 123 | } 124 | 125 | /** 126 | * Get Generic.
127 | * Get a item of the array, you should not get used to use this, better use specific get's. 128 | * 129 | * @param string $item The item of the $data array you want 130 | * @return array 131 | */ 132 | public function get($item = ''){ 133 | return (empty($item)) ? $this->_data : $this->_data[$item]; 134 | } 135 | 136 | //------------------------------------------------------------------------------ 137 | // Export 138 | //------------------------------------------------------------------------------ 139 | 140 | /** 141 | * Get the JSON representation of the Episode 142 | * 143 | * @return string 144 | */ 145 | public function getJSON() { 146 | return json_encode($this->_data, JSON_PRETTY_PRINT); 147 | } 148 | } 149 | ?> -------------------------------------------------------------------------------- /controller/classes/data/Genre.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 11/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class Genre { 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $_data; 20 | 21 | /** 22 | * Construct Class 23 | * 24 | * @param array $data An array with the data of a Collection 25 | */ 26 | public function __construct($data) { 27 | $this->_data = $data; 28 | } 29 | 30 | //------------------------------------------------------------------------------ 31 | // Get Variables 32 | //------------------------------------------------------------------------------ 33 | 34 | /** 35 | * Get the Genre's name 36 | * 37 | * @return string 38 | */ 39 | public function getName() { 40 | return $this->_data['name']; 41 | } 42 | 43 | /** 44 | * Get the Genre's id 45 | * 46 | * @return int 47 | */ 48 | public function getID() { 49 | return $this->_data['id']; 50 | } 51 | } 52 | ?> -------------------------------------------------------------------------------- /controller/classes/data/Movie.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.2 8 | * @date 02/04/2016 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | class Movie extends ApiBaseObject{ 13 | 14 | private $_tmdb; 15 | 16 | //------------------------------------------------------------------------------ 17 | // Get Variables 18 | //------------------------------------------------------------------------------ 19 | 20 | /** 21 | * Get the Movie's title 22 | * 23 | * @return string 24 | */ 25 | public function getTitle() { 26 | return $this->_data['title']; 27 | } 28 | 29 | /** 30 | * Get the Movie's tagline 31 | * 32 | * @return string 33 | */ 34 | public function getTagline() { 35 | return $this->_data['tagline']; 36 | } 37 | 38 | /** 39 | * Get the Movie Directors IDs 40 | * 41 | * @return array(int) 42 | */ 43 | public function getDirectorIds() { 44 | 45 | $director_ids = []; 46 | 47 | $crew = $this->getCrew(); 48 | 49 | /** @var Person $crew_member */ 50 | foreach ($crew as $crew_member) { 51 | 52 | if ($crew_member->getJob() === Person::JOB_DIRECTOR){ 53 | $director_ids[] = $crew_member->getID(); 54 | } 55 | } 56 | return $director_ids; 57 | } 58 | 59 | /** 60 | * Get the Movie's trailers 61 | * 62 | * @return array 63 | */ 64 | public function getTrailers() { 65 | return $this->_data['trailers']; 66 | } 67 | 68 | /** 69 | * Get the Movie's trailer 70 | * 71 | * @return string | null 72 | */ 73 | public function getTrailer() { 74 | $trailers = $this->getTrailers(); 75 | 76 | if (!array_key_exists('youtube', $trailers)) { 77 | return null; 78 | } 79 | 80 | if (count($trailers['youtube']) === 0) { 81 | return null; 82 | } 83 | 84 | return $trailers['youtube'][0]['source']; 85 | } 86 | 87 | /** 88 | * Get the Movie's reviews 89 | * 90 | * @return Review[] 91 | */ 92 | public function getReviews() { 93 | $reviews = array(); 94 | 95 | foreach ($this->_data['review']['result'] as $data) { 96 | $reviews[] = new Review($data); 97 | } 98 | 99 | return $reviews; 100 | } 101 | 102 | /** 103 | * Get the Movie's companies 104 | * 105 | * @return Company[] 106 | */ 107 | public function getCompanies() { 108 | $companies = array(); 109 | 110 | foreach ($this->_data['production_companies'] as $data) { 111 | $companies[] = new Company($data); 112 | } 113 | 114 | return $companies; 115 | } 116 | 117 | //------------------------------------------------------------------------------ 118 | // Import an API instance 119 | //------------------------------------------------------------------------------ 120 | 121 | /** 122 | * Set an instance of the API 123 | * 124 | * @param TMDB $tmdb An instance of the api, necessary for the lazy load 125 | */ 126 | public function setAPI($tmdb){ 127 | $this->_tmdb = $tmdb; 128 | } 129 | 130 | //------------------------------------------------------------------------------ 131 | // Export 132 | //------------------------------------------------------------------------------ 133 | 134 | /** 135 | * Get the JSON representation of the Movie 136 | * 137 | * @return string 138 | */ 139 | public function getJSON() { 140 | return json_encode($this->_data, JSON_PRETTY_PRINT); 141 | } 142 | 143 | 144 | /** 145 | * @return string 146 | */ 147 | public function getMediaType(){ 148 | return self::MEDIA_TYPE_MOVIE; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /controller/classes/data/Person.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 11/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class Person{ 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Constants 17 | //------------------------------------------------------------------------------ 18 | 19 | const MEDIA_TYPE_PERSON = 'person'; 20 | 21 | const JOB_DIRECTOR = 'Director'; 22 | 23 | //------------------------------------------------------------------------------ 24 | // Class Variables 25 | //------------------------------------------------------------------------------ 26 | 27 | private $_data; 28 | 29 | /** 30 | * Construct Class 31 | * 32 | * @param array $data An array with the data of the Person 33 | */ 34 | public function __construct($data) { 35 | $this->_data = $data; 36 | } 37 | 38 | //------------------------------------------------------------------------------ 39 | // Get Variables 40 | //------------------------------------------------------------------------------ 41 | 42 | /** 43 | * Get the Person's name 44 | * 45 | * @return string 46 | */ 47 | public function getName() { 48 | return $this->_data['name']; 49 | } 50 | 51 | /** 52 | * Get the Person's id 53 | * 54 | * @return int 55 | */ 56 | public function getID() { 57 | return $this->_data['id']; 58 | } 59 | 60 | /** 61 | * Get the Person's profile image 62 | * 63 | * @return string 64 | */ 65 | public function getProfile() { 66 | return $this->_data['profile_path']; 67 | } 68 | 69 | /** 70 | * Get the Person's birthday 71 | * 72 | * @return string 73 | */ 74 | public function getBirthday() { 75 | return $this->_data['birthday']; 76 | } 77 | 78 | /** 79 | * Get the Person's place of birth 80 | * 81 | * @return string 82 | */ 83 | public function getPlaceOfBirth() { 84 | return $this->_data['place_of_birth']; 85 | } 86 | 87 | /** 88 | * Get the Person's imdb id 89 | * 90 | * @return string 91 | */ 92 | public function getImbdID() { 93 | return $this->_data['imdb_id']; 94 | } 95 | 96 | /** 97 | * Get the Person's popularity 98 | * 99 | * @return int 100 | */ 101 | public function getPopularity() { 102 | return $this->_data['popularity']; 103 | } 104 | 105 | /** 106 | * Get the Person's popularity 107 | * 108 | * @return int 109 | */ 110 | public function getJob() { 111 | return $this->_data['job']; 112 | } 113 | 114 | /** 115 | * Get the Person's MovieRoles 116 | * 117 | * @return MovieRole[] 118 | */ 119 | public function getMovieRoles() { 120 | $movieRoles = array(); 121 | 122 | foreach($this->_data['movie_credits']['cast'] as $data){ 123 | $movieRoles[] = new MovieRole($data, $this->getID()); 124 | } 125 | 126 | return $movieRoles; 127 | } 128 | 129 | /** 130 | * Get the Person's TVShowRoles 131 | * 132 | * @return TVShowRole[] 133 | */ 134 | public function getTVShowRoles() { 135 | $tvShowRole = array(); 136 | 137 | foreach($this->_data['tv_credits']['cast'] as $data){ 138 | $tvShowRole[] = new TVShowRole($data, $this->getID()); 139 | } 140 | 141 | return $tvShowRole; 142 | } 143 | 144 | /** 145 | * Get Generic.
146 | * Get a item of the array, you should not get used to use this, better use specific get's. 147 | * 148 | * @param string $item The item of the $data array you want 149 | * @return array 150 | */ 151 | public function get($item = ''){ 152 | return (empty($item)) ? $this->_data : $this->_data[$item]; 153 | } 154 | 155 | //------------------------------------------------------------------------------ 156 | // Export 157 | //------------------------------------------------------------------------------ 158 | 159 | /** 160 | * Get the JSON representation of the Episode 161 | * 162 | * @return string 163 | */ 164 | public function getJSON() { 165 | return json_encode($this->_data, JSON_PRETTY_PRINT); 166 | } 167 | 168 | 169 | /** 170 | * @return string 171 | */ 172 | public function getMediaType(){ 173 | return self::MEDIA_TYPE_PERSON; 174 | } 175 | } 176 | ?> -------------------------------------------------------------------------------- /controller/classes/data/Review.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 31/03/2016 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class Review { 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $_data; 20 | 21 | /** 22 | * Construct Class 23 | * 24 | * @param array $data An array with the data of a Review 25 | */ 26 | public function __construct($data) { 27 | $this->_data = $data; 28 | } 29 | 30 | //------------------------------------------------------------------------------ 31 | // Get Variables 32 | //------------------------------------------------------------------------------ 33 | 34 | /** 35 | * Get the Review's id 36 | * 37 | * @return int 38 | **/ 39 | public function getID() { 40 | return $this->_data['id']; 41 | } 42 | 43 | /** 44 | * Get the Review's author 45 | * 46 | * @return string 47 | */ 48 | public function getAuthor() { 49 | return $this->_data['author']; 50 | } 51 | 52 | /** 53 | * Get the Review's content 54 | * 55 | * @return string 56 | */ 57 | public function getContent() { 58 | return $this->_data['content']; 59 | } 60 | 61 | /** 62 | * Get the Review's url 63 | * 64 | * @return string 65 | */ 66 | public function getURL() { 67 | return $this->_data['url']; 68 | } 69 | 70 | /** 71 | * Get Generic.
72 | * Get a item of the array, you should not get used to use this, better use specific get's. 73 | * 74 | * @param string $item The item of the $data array you want 75 | * @return array 76 | */ 77 | public function get($item = ''){ 78 | return (empty($item)) ? $this->_data : $this->_data[$item]; 79 | } 80 | 81 | //------------------------------------------------------------------------------ 82 | // Export 83 | //------------------------------------------------------------------------------ 84 | 85 | /** 86 | * Get the JSON representation of the Movie 87 | * 88 | * @return string 89 | */ 90 | public function getJSON() { 91 | return json_encode($this->_data, JSON_PRETTY_PRINT); 92 | } 93 | } 94 | ?> -------------------------------------------------------------------------------- /controller/classes/data/Role.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 11/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class Role{ 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $_data; 20 | 21 | /** 22 | * Construct Class 23 | * 24 | * @param array $data An array with the data of a Role 25 | */ 26 | protected function __construct($data, $ipPerson) { 27 | $this->_data = $data; 28 | $this->_data['person_id'] = $ipPerson; 29 | } 30 | 31 | //------------------------------------------------------------------------------ 32 | // Get Variables 33 | //------------------------------------------------------------------------------ 34 | 35 | /** 36 | * Get the Role's character 37 | * 38 | * @return string 39 | */ 40 | public function getCharacter() { 41 | return $this->_data['character']; 42 | } 43 | 44 | /** 45 | * Get the Movie's poster 46 | * 47 | * @return string 48 | */ 49 | public function getPoster() { 50 | return $this->_data['poster_path']; 51 | } 52 | 53 | /** 54 | * Get Generic.
55 | * Get a item of the array, you should not get used to use this, better use specific get's. 56 | * 57 | * @param string $item The item of the $data array you want 58 | * @return array 59 | */ 60 | public function get($item = ''){ 61 | return (empty($item)) ? $this->_data : $this->_data[$item]; 62 | } 63 | } 64 | ?> 65 | -------------------------------------------------------------------------------- /controller/classes/data/Season.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 11/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class Season{ 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $_data; 20 | private $_idTVShow; 21 | 22 | /** 23 | * Construct Class 24 | * 25 | * @param array $data An array with the data of the Season 26 | */ 27 | public function __construct($data, $idTVShow = 0) { 28 | $this->_data = $data; 29 | $this->_data['tvshow_id'] = $idTVShow; 30 | } 31 | 32 | //------------------------------------------------------------------------------ 33 | // Get Variables 34 | //------------------------------------------------------------------------------ 35 | 36 | /** 37 | * Get the Season's id 38 | * 39 | * @return int 40 | */ 41 | public function getID() { 42 | return $this->_data['id']; 43 | } 44 | 45 | /** 46 | * Get the Season's name 47 | * 48 | * @return string 49 | */ 50 | public function getName() { 51 | return $this->_data['name']; 52 | } 53 | 54 | /** 55 | * Get the Season's TVShow id 56 | * 57 | * @return int 58 | */ 59 | public function getTVShowID() { 60 | return $this->_data['tvshow_id']; 61 | } 62 | 63 | /** 64 | * Get the Season's number 65 | * 66 | * @return int 67 | */ 68 | public function getSeasonNumber() { 69 | return $this->_data['season_number']; 70 | } 71 | 72 | /** 73 | * Get the Season's number of episodes 74 | * 75 | * @return int 76 | */ 77 | public function getNumEpisodes() { 78 | return count($this->_data['episodes']); 79 | } 80 | 81 | /** 82 | * Get a Seasons's Episode 83 | * 84 | * @param int $numEpisode The episode number 85 | * @return int 86 | */ 87 | public function getEpisode($numEpisode) { 88 | return new Episode($this->_data['episodes'][$numEpisode]); 89 | } 90 | 91 | /** 92 | * Get a Seasons's Episode Count 93 | * 94 | * @param int $numEpisode The episode number 95 | * @return int 96 | */ 97 | public function getEpisodeCount() { 98 | return $this->_data['episode_count']; 99 | } 100 | 101 | /** 102 | * Get the Season's Episodes 103 | * 104 | * @return Episode[] 105 | */ 106 | public function getEpisodes() { 107 | $episodes = array(); 108 | 109 | foreach($this->_data['episodes'] as $data){ 110 | $episodes[] = new Episode($data, $this->getTVShowID()); 111 | } 112 | 113 | return $episodes; 114 | } 115 | 116 | /** 117 | * Get the Seasons's Poster 118 | * 119 | * @return string 120 | */ 121 | public function getPoster() { 122 | return $this->_data['poster_path']; 123 | } 124 | 125 | /** 126 | * Get the Season's AirDate 127 | * 128 | * @return string 129 | */ 130 | public function getAirDate() { 131 | return $this->_data['air_date']; 132 | } 133 | 134 | /** 135 | * Get Generic.
136 | * Get a item of the array, you should not get used to use this, better use specific get's. 137 | * 138 | * @param string $item The item of the $data array you want 139 | * @return array 140 | */ 141 | public function get($item = '') { 142 | return (empty($item)) ? $this->_data : $this->_data[$item]; 143 | } 144 | 145 | //------------------------------------------------------------------------------ 146 | // Export 147 | //------------------------------------------------------------------------------ 148 | 149 | /** 150 | * Get the JSON representation of the Season 151 | * 152 | * @return string 153 | */ 154 | public function getJSON() { 155 | return json_encode($this->_data, JSON_PRETTY_PRINT); 156 | } 157 | } 158 | ?> -------------------------------------------------------------------------------- /controller/classes/data/TVShow.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 11/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class TVShow extends ApiBaseObject{ 14 | 15 | //------------------------------------------------------------------------------ 16 | // Get Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | /** 20 | * Get the TVShow's name 21 | * 22 | * @return string 23 | */ 24 | public function getName() { 25 | return $this->_data['name']; 26 | } 27 | 28 | /** 29 | * Get the TVShow's original name 30 | * 31 | * @return string 32 | */ 33 | public function getOriginalName() { 34 | return $this->_data['original_name']; 35 | } 36 | 37 | /** 38 | * Get the TVShow's number of seasons 39 | * 40 | * @return int 41 | */ 42 | public function getNumSeasons() { 43 | return $this->_data['number_of_seasons']; 44 | } 45 | 46 | /** 47 | * Get the TVShow's number of episodes 48 | * 49 | * @return int 50 | */ 51 | public function getNumEpisodes() { 52 | return $this->_data['number_of_episodes']; 53 | } 54 | 55 | /** 56 | * Get a TVShow's season 57 | * 58 | * @param int $numSeason The season number 59 | * @return int 60 | */ 61 | public function getSeason($numSeason) { 62 | $data = null; 63 | 64 | foreach($this->_data['seasons'] as $season){ 65 | if ($season['season_number'] == $numSeason){ 66 | $data = $season; 67 | break; 68 | } 69 | } 70 | return new Season($data); 71 | } 72 | 73 | /** 74 | * Get the TvShow's seasons 75 | * 76 | * @return Season[] 77 | */ 78 | public function getSeasons() { 79 | $seasons = array(); 80 | 81 | foreach($this->_data['seasons'] as $data){ 82 | $seasons[] = new Season($data, $this->getID()); 83 | } 84 | 85 | return $seasons; 86 | } 87 | 88 | public function getVideos() { 89 | $videos = $this->_data['videos']; 90 | 91 | if (array_key_exists('results', $videos)) { 92 | return $videos['results']; 93 | } 94 | 95 | return []; 96 | } 97 | 98 | /** 99 | * Get the TVShow's trailers 100 | * 101 | * @return array 102 | */ 103 | public function getTrailers() { 104 | $trailers = []; 105 | $videos = $this->getVideos(); 106 | 107 | foreach($videos as $video) { 108 | if($video['type'] !== 'Trailer') { 109 | continue; 110 | } 111 | 112 | if($video['site'] !== 'YouTube'){ 113 | continue; 114 | } 115 | 116 | $trailers[] = $video; 117 | } 118 | 119 | return $trailers; 120 | } 121 | 122 | /** 123 | * Get the TVShow's Backdrop 124 | * 125 | * @return string 126 | */ 127 | public function getBackdrop() { 128 | return $this->_data['backdrop_path']; 129 | } 130 | 131 | /** 132 | * Get the TVShow's Overview 133 | * 134 | * @return string 135 | */ 136 | public function getOverview() { 137 | return $this->_data['overview']; 138 | } 139 | 140 | /** 141 | * Get if the TVShow is in production 142 | * 143 | * @return boolean 144 | */ 145 | public function getInProduction() { 146 | return $this->_data['in_production']; 147 | } 148 | 149 | //------------------------------------------------------------------------------ 150 | // Export 151 | //------------------------------------------------------------------------------ 152 | 153 | /** 154 | * Get the JSON representation of the TVShow 155 | * 156 | * @return string 157 | */ 158 | public function getJSON() { 159 | return json_encode($this->_data, JSON_PRETTY_PRINT); 160 | } 161 | 162 | /** 163 | * @return string 164 | */ 165 | public function getMediaType(){ 166 | return self::MEDIA_TYPE_TV; 167 | } 168 | } -------------------------------------------------------------------------------- /controller/classes/jobs/MovieJob.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @author Kostas Stathakos | e-leven.net 8 | * @version 0.1 9 | * @date 01/11/2017 10 | * @link https://github.com/pixelead0/tmdb_v3-PHP-API- 11 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 12 | */ 13 | 14 | class MovieJob { 15 | 16 | //------------------------------------------------------------------------------ 17 | // Class Variables 18 | //------------------------------------------------------------------------------ 19 | 20 | private $_data; 21 | 22 | /** 23 | * Construct Class 24 | * 25 | * @param array $data An array with the data of a Movie job 26 | */ 27 | public function __construct($data, $ipPerson) { 28 | $this->_data = $data; 29 | $this->_data['person_id'] = $ipPerson; 30 | } 31 | 32 | //------------------------------------------------------------------------------ 33 | // Get Variables 34 | //------------------------------------------------------------------------------ 35 | 36 | /** 37 | * Get the Movie's title 38 | * 39 | * @return string 40 | */ 41 | public function getMovieTitle() { 42 | return $this->_data['title']; 43 | } 44 | 45 | /** 46 | * Get the Movie's id 47 | * 48 | * @return int 49 | */ 50 | public function getMovieID() { 51 | return $this->_data['id']; 52 | } 53 | 54 | /** 55 | * Get the Movie's original title 56 | * 57 | * @return string 58 | */ 59 | public function getMovieOriginalTitle() { 60 | return $this->_data['original_title']; 61 | } 62 | 63 | /** 64 | * Get the Movie's release date 65 | * 66 | * @return string 67 | */ 68 | public function getMovieReleaseDate() { 69 | return $this->_data['release_date']; 70 | } 71 | 72 | 73 | /** 74 | * Get the Movie's poster 75 | * 76 | * @return string 77 | */ 78 | public function getPoster() { 79 | return $this->_data['poster_path']; 80 | } 81 | 82 | /** 83 | * Get the name of the job 84 | * 85 | * @return string 86 | */ 87 | public function getMovieJob() { 88 | return $this->_data['job']; 89 | } 90 | 91 | 92 | /** 93 | * Get the job department 94 | * 95 | * @return string 96 | */ 97 | public function getMovieDepartment() { 98 | return $this->_data['department']; 99 | } 100 | 101 | /** 102 | * Get the Movie's overview 103 | * 104 | * @return string 105 | */ 106 | public function getMovieOverview() { 107 | return $this->_data['overview']; 108 | } 109 | 110 | 111 | //------------------------------------------------------------------------------ 112 | // Export 113 | //------------------------------------------------------------------------------ 114 | 115 | /** 116 | * Get the JSON representation of the Movie job 117 | * 118 | * @return string 119 | */ 120 | public function getJSON() { 121 | return json_encode($this->_data, JSON_PRETTY_PRINT); 122 | } 123 | } 124 | ?> 125 | -------------------------------------------------------------------------------- /controller/classes/jobs/TVShowJob.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @author Kostas Stathakos | e-leven.net 8 | * @version 0.1 9 | * @date 01/11/2017 10 | * @link https://github.com/pixelead0/tmdb_v3-PHP-API- 11 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 12 | */ 13 | 14 | class TVShowJob { 15 | 16 | //------------------------------------------------------------------------------ 17 | // Class Variables 18 | //------------------------------------------------------------------------------ 19 | 20 | private $_data; 21 | 22 | /** 23 | * Construct Class 24 | * 25 | * @param array $data An array with the data of a TVShow job 26 | */ 27 | public function __construct($data, $ipPerson) { 28 | $this->_data = $data; 29 | $this->_data['person_id'] = $ipPerson; 30 | } 31 | 32 | //------------------------------------------------------------------------------ 33 | // Get Variables 34 | //------------------------------------------------------------------------------ 35 | 36 | /** 37 | * Get the TVShow's title 38 | * 39 | * @return string 40 | */ 41 | public function getTVShowName() { 42 | return $this->_data['name']; 43 | } 44 | 45 | /** 46 | * Get the TVShow's id 47 | * 48 | * @return int 49 | */ 50 | public function getTVShowID() { 51 | return $this->_data['id']; 52 | } 53 | 54 | /** 55 | * Get the TVShow's original title 56 | * 57 | * @return string 58 | */ 59 | public function getTVShowOriginalTitle() { 60 | return $this->_data['original_name']; 61 | } 62 | 63 | /** 64 | * Get the TVShow's release date 65 | * 66 | * @return string 67 | */ 68 | public function getTVShowFirstAirDate() { 69 | return $this->_data['first_air_date']; 70 | } 71 | 72 | /** 73 | * Get the TVShow's poster 74 | * 75 | * @return string 76 | */ 77 | public function getPoster() { 78 | return $this->_data['backdrop_path']; 79 | } 80 | 81 | /** 82 | * Get the name of the job 83 | * 84 | * @return string 85 | */ 86 | public function getTVShowJob() { 87 | return $this->_data['job']; 88 | } 89 | 90 | /** 91 | * Get the job department 92 | * 93 | * @return string 94 | */ 95 | public function getTVShowDepartment() { 96 | return $this->_data['department']; 97 | } 98 | 99 | /** 100 | * Get the TVShow's overview 101 | * 102 | * @return string 103 | */ 104 | public function getTVShowOverview() { 105 | return $this->_data['overview']; 106 | } 107 | 108 | /** 109 | * Get the TVShow's episode count 110 | * 111 | * @return string 112 | */ 113 | public function getTVShowEpisodeCount() { 114 | return $this->_data['episode_count']; 115 | } 116 | 117 | 118 | //------------------------------------------------------------------------------ 119 | // Export 120 | //------------------------------------------------------------------------------ 121 | 122 | /** 123 | * Get the JSON representation of the TVShow job 124 | * 125 | * @return string 126 | */ 127 | public function getJSON() { 128 | return json_encode($this->_data, JSON_PRETTY_PRINT); 129 | } 130 | } 131 | ?> 132 | -------------------------------------------------------------------------------- /controller/classes/roles/MovieRole.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 11/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class MovieRole extends Role{ 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $_data; 20 | 21 | /** 22 | * Construct Class 23 | * 24 | * @param array $data An array with the data of a MovieRole 25 | */ 26 | public function __construct($data, $idPerson) { 27 | $this->_data = $data; 28 | 29 | parent::__construct($data, $idPerson); 30 | } 31 | 32 | //------------------------------------------------------------------------------ 33 | // Get Variables 34 | //------------------------------------------------------------------------------ 35 | 36 | /** 37 | * Get the Movie's title of the role 38 | * 39 | * @return string 40 | */ 41 | public function getMovieTitle() { 42 | return $this->_data['title']; 43 | } 44 | 45 | /** 46 | * Get the Movie's id 47 | * 48 | * @return int 49 | */ 50 | public function getMovieID() { 51 | return $this->_data['id']; 52 | } 53 | 54 | /** 55 | * Get the Movie's original title of the role 56 | * 57 | * @return string 58 | */ 59 | public function getMovieOriginalTitle() { 60 | return $this->_data['original_title']; 61 | } 62 | 63 | /** 64 | * Get the Movie's release date of the role 65 | * 66 | * @return string 67 | */ 68 | public function getMovieReleaseDate() { 69 | return $this->_data['release_date']; 70 | } 71 | 72 | //------------------------------------------------------------------------------ 73 | // Export 74 | //------------------------------------------------------------------------------ 75 | 76 | /** 77 | * Get the JSON representation of the Episode 78 | * 79 | * @return string 80 | */ 81 | public function getJSON() { 82 | return json_encode($this->_data, JSON_PRETTY_PRINT); 83 | } 84 | } 85 | ?> -------------------------------------------------------------------------------- /controller/classes/roles/TVShowRole.php: -------------------------------------------------------------------------------- 1 | Twitter 7 | * @version 0.1 8 | * @date 11/01/2015 9 | * @link https://github.com/Alvaroctal/TMDB-PHP-API 10 | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 11 | */ 12 | 13 | class TVShowRole extends Role{ 14 | 15 | //------------------------------------------------------------------------------ 16 | // Class Variables 17 | //------------------------------------------------------------------------------ 18 | 19 | private $_data; 20 | 21 | /** 22 | * Construct Class 23 | * 24 | * @param array $data An array with the data of a TVShowRole 25 | */ 26 | public function __construct($data, $idPerson) { 27 | $this->_data = $data; 28 | 29 | parent::__construct($data, $idPerson); 30 | } 31 | 32 | //------------------------------------------------------------------------------ 33 | // Get Variables 34 | //------------------------------------------------------------------------------ 35 | 36 | /** 37 | * Get the TVShow's title of the role 38 | * 39 | * @return string 40 | */ 41 | public function getTVShowName() { 42 | return $this->_data['name']; 43 | } 44 | 45 | /** 46 | * Get the TVShow's id 47 | * 48 | * @return int 49 | */ 50 | public function getTVShowID() { 51 | return $this->_data['id']; 52 | } 53 | 54 | /** 55 | * Get the TVShow's original title of the role 56 | * 57 | * @return string 58 | */ 59 | public function getTVShowOriginalTitle() { 60 | return $this->_data['original_name']; 61 | } 62 | 63 | /** 64 | * Get the TVShow's release date of the role 65 | * 66 | * @return string 67 | */ 68 | public function getTVShowFirstAirDate() { 69 | return $this->_data['first_air_date']; 70 | } 71 | 72 | //------------------------------------------------------------------------------ 73 | // Export 74 | //------------------------------------------------------------------------------ 75 | 76 | /** 77 | * Get the JSON representation of the Episode 78 | * 79 | * @return string 80 | */ 81 | public function getJSON() { 82 | return json_encode($this->_data, JSON_PRETTY_PRINT); 83 | } 84 | } 85 | ?> -------------------------------------------------------------------------------- /examples/.htaccess: -------------------------------------------------------------------------------- 1 | php_flag display_startup_errors on 2 | php_flag display_errors on 3 | php_flag html_errors on -------------------------------------------------------------------------------- /examples/genres/movieGenres.php: -------------------------------------------------------------------------------- 1 | getMovieGenres(); 3 | echo '
4 |
5 | 15 |
16 |
'; 17 | ?> -------------------------------------------------------------------------------- /examples/genres/tvShowGenres.php: -------------------------------------------------------------------------------- 1 | getTVGenres(); 3 | echo '
4 |
5 | 15 |
16 |
'; 17 | ?> -------------------------------------------------------------------------------- /examples/index.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | TMDB PHP API - Examples 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 38 | 39 | 40 | 41 | 42 | 43 | 145 | 146 | 147 | 148 |
149 |

150 | 151 | 168 |
169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /examples/movies/featuredMovies.php: -------------------------------------------------------------------------------- 1 | getLatestMovie(); 6 | echo '
7 |
8 | Latest Movie 9 |
10 |
11 | '. $movie->getTitle() .' ('. $movie->getID() .')
12 |
13 |
'; 14 | 15 | // Now Playing Movie 16 | 17 | $movies = $tmdb->getNowPlayingMovies(); 18 | echo '
19 |
20 | Now Playing Movies 21 |
22 |
23 | 28 |
29 |
'; 30 | 31 | // Popular Movies 32 | 33 | $movies = $tmdb->getPopularMovies(); 34 | echo '
35 |
36 | Popular Movies 37 |
38 |
39 | 44 |
45 |
'; 46 | 47 | // Top Rated Movies 48 | 49 | $movies = $tmdb->getTopRatedMovies(); 50 | echo '
51 |
52 | Top Rated Movies 53 |
54 |
55 | 60 |
61 |
'; 62 | 63 | // Upcoming Movies 64 | 65 | $movies = $tmdb->getUpcomingMovies(); 66 | echo '
67 |
68 | Upcoming Movies 69 |
70 |
71 | 76 |
77 |
'; 78 | ?> -------------------------------------------------------------------------------- /examples/movies/findMovie.php: -------------------------------------------------------------------------------- 1 | find('tt0133093'); 3 | $movies = $found['movies']; 4 | 5 | echo '
6 |
7 | tt0133093 would be a IMDB id. 8 | 13 |
14 |
'; 15 | ?> -------------------------------------------------------------------------------- /examples/movies/infoCollection.php: -------------------------------------------------------------------------------- 1 | getCollection(121938); 3 | 4 | echo '
5 |
6 | Now the $collection var got all the data, check the documentation for the complete list of methods.

7 | 8 | ' . 9 | $collection->getName() . 10 | ' 11 | 33 | 37 |
38 |
'; 39 | ?> 40 | -------------------------------------------------------------------------------- /examples/movies/infoCompany.php: -------------------------------------------------------------------------------- 1 | getCompany(34); 3 | 4 | echo '
5 |
6 | Now the $company var got all the data, check the documentation for the complete list of methods.

7 | 8 | ' . 9 | $company->getName() . 10 | ' 11 | 35 | 39 |
40 |
'; 41 | ?> 42 | -------------------------------------------------------------------------------- /examples/movies/infoMovie.php: -------------------------------------------------------------------------------- 1 | getMovie(11); 3 | echo '
4 |
5 | Now the $movie var got all the data, check the documentation for the complete list of methods.

6 | 7 | ' . 8 | $movie->getTitle() . 9 | ' 10 | 21 | 25 | 36 | 56 |
57 |
'; 58 | ?> 59 | -------------------------------------------------------------------------------- /examples/movies/searchCollection.php: -------------------------------------------------------------------------------- 1 | searchCollection("the hobbit"); 4 | 5 | echo '
6 |
7 | 12 |
13 |
'; 14 | ?> -------------------------------------------------------------------------------- /examples/movies/searchCompany.php: -------------------------------------------------------------------------------- 1 | searchCompany("Sony"); 4 | 5 | echo '
6 |
7 | 12 |
13 |
'; 14 | ?> -------------------------------------------------------------------------------- /examples/movies/searchMovie.php: -------------------------------------------------------------------------------- 1 | searchMovie("underworld"); 3 | 4 | echo '
5 |
6 | 13 |
14 |
'; 15 | ?> -------------------------------------------------------------------------------- /examples/movies/searchMovieByGenre.php: -------------------------------------------------------------------------------- 1 | getMoviesByGenre(28); 3 | 4 | echo '
5 |
6 | 13 |
14 |
'; 15 | ?> -------------------------------------------------------------------------------- /examples/people/featuredPersons.php: -------------------------------------------------------------------------------- 1 | getLatestPerson(); 5 | echo '
6 |
7 | Latest Person 8 |
9 |
10 | '. $person->getName() .' ('. $person->getID() .') 11 |
12 |
'; 13 | 14 | // On The Air TVShows 15 | 16 | $persons = $tmdb->getPopularPersons(); 17 | echo '
18 |
19 | Popular persons 20 |
21 |
22 | 27 |
28 |
'; 29 | ?> -------------------------------------------------------------------------------- /examples/people/findPerson.php: -------------------------------------------------------------------------------- 1 | find('nm0000652'); 3 | $persons = $found['persons']; 4 | 5 | echo '
6 |
7 | tt3032476 would be a IMDB id. 8 | 13 |
14 |
'; 15 | ?> -------------------------------------------------------------------------------- /examples/people/infoPerson.php: -------------------------------------------------------------------------------- 1 | getPerson(85); 3 | 4 | echo '
5 |
6 | Now the $person var got all the data, check the documentation for the complete list of methods.

7 | 8 | ' . 9 | $person->getName() . 10 | ' 11 | 22 | 26 |
27 |
'; 28 | ?> 29 | -------------------------------------------------------------------------------- /examples/people/infoRoles.php: -------------------------------------------------------------------------------- 1 | getPerson(85); 3 | 4 | echo '
5 |
6 | Now each $movieRole var got all the data, check the documentation for the complete list of methods.

'; 7 | 8 | $movieRoles = $person->getMovieRoles(); 9 | echo ' ' . 10 | $person->getName() . 11 | ' - Roles in Movies: 12 |

23 | 24 | Now the $tvShowRole var got all the data, check the documentation for the complete list of methods.

'; 25 | 26 | $tvShowRoles = $person->getTVShowRoles(); 27 | echo ' ' . 28 | $person->getName() . 29 | ' - Roles in TVShows: 30 | 41 |
42 |
'; 43 | -------------------------------------------------------------------------------- /examples/people/searchPerson.php: -------------------------------------------------------------------------------- 1 | searchPerson("Johnny"); 3 | 4 | echo '
5 |
6 | 11 |
12 |
'; 13 | ?> -------------------------------------------------------------------------------- /examples/search/multiSearch.php: -------------------------------------------------------------------------------- 1 | multiSearch("Wesley"); 3 | 4 | foreach($multiSearchResults as $mediaType => $searchResults){ 5 | echo '
'; 6 | echo '
'.$mediaType.'
'; 7 | echo '
'; 8 | echo '
'; 19 | } 20 | ?> -------------------------------------------------------------------------------- /examples/tvshows/featuredTVShows.php: -------------------------------------------------------------------------------- 1 | getLatestTVShow(); 6 | echo '
7 |
8 | Latest TVShow 9 |
10 |
11 | '. $tvShow->getName() .' ('. $tvShow->getID() .') 12 |
13 |
'; 14 | 15 | // On The Air TVShows 16 | 17 | $tvShows = $tmdb->getOnTheAirTVShows(); 18 | echo '
19 |
20 | On The Air TVShows 21 |
22 |
23 | 28 |
29 |
'; 30 | 31 | // Airing Today TVShows 32 | 33 | $tvShows = $tmdb->getAiringTodayTVShows(); 34 | echo '
35 |
36 | Airing Today TVShows 37 |
38 |
39 | 44 |
45 |
'; 46 | 47 | // Top Rated TVShows 48 | 49 | $tvShows = $tmdb->getTopRatedTVShows(); 50 | echo '
51 |
52 | Top Rated TVShows 53 |
54 |
55 | 60 |
61 |
'; 62 | 63 | // Popular TVShows 64 | 65 | $tvShows = $tmdb->getPopularTVShows(); 66 | echo '
67 |
68 | Popular TVShows 69 |
70 |
71 | 76 |
77 |
'; 78 | 79 | ?> -------------------------------------------------------------------------------- /examples/tvshows/findTVShow.php: -------------------------------------------------------------------------------- 1 | find('tt3032476'); 3 | $tvShows = $found['tvshows']; 4 | 5 | echo '
6 |
7 | tt3032476 would be a IMDB id. 8 | 13 |
14 |
'; 15 | ?> -------------------------------------------------------------------------------- /examples/tvshows/infoEpisode.php: -------------------------------------------------------------------------------- 1 | getEpisode(1396, 2, 8); 3 | 4 | echo '
5 |
6 | Now the $episode var got all the data, check the documentation for the complete list of methods.

7 | 8 | ' . 9 | $episode->getEpisodeNumber() . 10 | ' - ' . 11 | $episode->getName() . 12 | ' 13 | 27 |
28 |
'; 29 | ?> 30 | -------------------------------------------------------------------------------- /examples/tvshows/infoSeason.php: -------------------------------------------------------------------------------- 1 | getSeason(1396, 2); 3 | 4 | echo '
5 |
6 | Now the $season var got all the data, check the documentation for the complete list of methods.

7 | ' . 8 | $season->getName() . 9 | ' 10 | 39 |
40 |
'; 41 | -------------------------------------------------------------------------------- /examples/tvshows/infoTVShow.php: -------------------------------------------------------------------------------- 1 | getTVShow(1396); 3 | 4 | echo '
5 |
6 | Now the $tvShow var got all the data, check the documentation for the complete list of methods.

7 | 8 | ' . 9 | $tvShow->getName() . 10 | ' 11 | 43 | 47 | 58 | 78 |
79 |
'; 80 | -------------------------------------------------------------------------------- /examples/tvshows/searchTVShow.php: -------------------------------------------------------------------------------- 1 | searchTVShow("breaking bad"); 3 | 4 | echo '
5 |
6 | 11 |
12 |
'; 13 | ?> -------------------------------------------------------------------------------- /tmdb-api.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 2012 pixelead0 11 | * @date 2012-02-12 12 | * @link http://www.github.com/pixelead 13 | * @version 0.0.2 14 | * @license BSD http://www.opensource.org/licenses/bsd-license.php 15 | * 16 | * Portions of this file are based on pieces of TMDb PHP API class - API 'themoviedb.org' 17 | * @Copyright Jonas De Smet - Glamorous | https://github.com/glamorous/TMDb-PHP-API 18 | * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 19 | * @date 10.12.2010 20 | * @version 0.9.10 21 | * @author Jonas De Smet - Glamorous 22 | * @link {https://github.com/glamorous/TMDb-PHP-API} 23 | * 24 | * Added config class to make external configuration more easy 25 | * @Copyright Deso85 | https://github.com/deso85/TMDB-PHP-API 26 | * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) 27 | * @date 02.04.2016 28 | * @version 0.5 29 | * @author Deso85 30 | * @link {https://github.com/deso85/TMDB-PHP-API} 31 | * 32 | * Function List 33 | * public function __construct($config = null) 34 | * public function setAPIKey($apikey) 35 | * public function setLang($lang = "en") 36 | * public function getLang() 37 | * public function setTimeZone($timezone = 'Europe/Berlin') 38 | * public function getTimeZone() 39 | * public function setAdult($adult = false) 40 | * public function getAdult() 41 | * public function setDebug($debug = false) 42 | * public function getDebug() 43 | * public function getAPIConfig() 44 | * public function getImageURL($size = "original") 45 | * public function getDiscoverMovies($page = 1) 46 | * public function getDiscoverTVShows($page = 1) 47 | * public function getDiscoverMovie($page = 1) 48 | * public function getLatestMovie() 49 | * public function getNowPlayingMovies($page = 1) 50 | * public function getPopularMovies($page = 1) 51 | * public function getTopRatedMovies($page = 1) 52 | * public function getUpcomingMovies($page = 1) 53 | * public function getLatestTVShow() 54 | * public function getOnTheAirTVShows($page = 1) 55 | * public function getAiringTodayTVShows($page = 1, $timeZone = null) 56 | * public function getTopRatedTVShows($page = 1) 57 | * public function getPopularTVShows($page = 1) 58 | * public function getLatestPerson() 59 | * public function getPopularPersons($page = 1) 60 | * public function getMovie($idMovie, $appendToResponse = null) 61 | * public function getTVShow($idTVShow, $appendToResponse = null) 62 | * public function getSeason($idTVShow, $numSeason, $appendToResponse = null) 63 | * public function getEpisode($idTVShow, $numSeason, $numEpisode, $appendToResponse = null) 64 | * public function getPerson($idPerson, $appendToResponse = null) 65 | * public function getCollection($idCollection, $appendToResponse = null) 66 | * public function getCompany($idCompany, $appendToResponse = null) 67 | * public function searchMovie($movieTitle) 68 | * public function searchTVShow($tvShowTitle) 69 | * public function searchPerson($personName) 70 | * public function searchCollection($collectionName) 71 | * public function searchCompany($companyName) 72 | * public function find($id, $external_source = 'imdb_id') 73 | * public function getTimezones() 74 | * public function getJobs() 75 | * public function getMovieGenres() 76 | * public function getTVGenres() 77 | * public function getMoviesByGenre($idGenre, $page = 1) 78 | * public function multiSearch($searchQuery) 79 | * 80 | * private function _loadConfig() 81 | * private function setConfig($config) 82 | * private function getConfig() 83 | * private function _call($action, $appendToResponse = '') 84 | * 85 | * 86 | * URL LIST: 87 | * configuration http://api.themoviedb.org/3/configuration 88 | * Image http://cf2.imgobject.com/t/p/original/IMAGEN.jpg #### echar un ojo #### 89 | * Search Movie http://api.themoviedb.org/3/search/movie 90 | * Search Person http://api.themoviedb.org/3/search/person 91 | * Movie Info http://api.themoviedb.org/3/movie/11 92 | * Casts http://api.themoviedb.org/3/movie/11/casts 93 | * Posters http://api.themoviedb.org/3/movie/11/images 94 | * Trailers http://api.themoviedb.org/3/movie/11/trailers 95 | * translations http://api.themoviedb.org/3/movie/11/translations 96 | * Alternative titles http://api.themoviedb.org/3/movie/11/alternative_titles 97 | * 98 | * Collection Info http://api.themoviedb.org/3/collection/11 99 | * Person images http://api.themoviedb.org/3/person/287/images 100 | */ 101 | 102 | require ("controller/classes/data/ApiBaseObject.php"); 103 | require ("controller/classes/data/Collection.php"); 104 | require ("controller/classes/data/Company.php"); 105 | require ("controller/classes/data/Episode.php"); 106 | require ("controller/classes/data/Genre.php"); 107 | require ("controller/classes/data/Movie.php"); 108 | require ("controller/classes/data/Person.php"); 109 | require ("controller/classes/data/Role.php"); 110 | require ("controller/classes/data/Season.php"); 111 | require ("controller/classes/data/TVShow.php"); 112 | require ("controller/classes/roles/MovieRole.php"); 113 | require ("controller/classes/roles/TVShowRole.php"); 114 | require ("controller/classes/config/APIConfiguration.php"); 115 | require ("controller/classes/config/Configuration.php"); 116 | 117 | 118 | class TMDB { 119 | 120 | #@var string url of API TMDB 121 | const _API_URL_ = "http://api.themoviedb.org/3/"; 122 | 123 | #@var string Version of this class 124 | const VERSION = '0.5'; 125 | 126 | #@var array of config parameters 127 | private $config; 128 | 129 | #@var array of TMDB config 130 | private $apiconfiguration; 131 | 132 | /** 133 | * Construct Class 134 | * 135 | * @param array $cnf The necessary configuration 136 | */ 137 | public function __construct($config = null) { 138 | 139 | // Set configuration 140 | $this->setConfig($config); 141 | 142 | // Load the API configuration 143 | if (! $this->_loadConfig()){ 144 | echo _("Unable to read configuration, verify that the API key is valid"); 145 | exit; 146 | } 147 | } 148 | 149 | //------------------------------------------------------------------------------ 150 | // Configuration Parameters 151 | //------------------------------------------------------------------------------ 152 | 153 | /** 154 | * Set configuration parameters 155 | * 156 | * @param array $config 157 | */ 158 | private function setConfig($config) { 159 | $this->config = new Configuration($config); 160 | } 161 | 162 | /** 163 | * Get the config parameters 164 | * 165 | * @return array $config 166 | */ 167 | private function getConfig() { 168 | return $this->config; 169 | } 170 | 171 | //------------------------------------------------------------------------------ 172 | // API Key 173 | //------------------------------------------------------------------------------ 174 | 175 | /** 176 | * Set the API Key 177 | * 178 | * @param string $apikey 179 | */ 180 | public function setAPIKey($apikey) { 181 | $this->getConfig()->setAPIKey($apikey); 182 | } 183 | 184 | //------------------------------------------------------------------------------ 185 | // Language 186 | //------------------------------------------------------------------------------ 187 | 188 | /** 189 | * Set the language 190 | * By default english 191 | * 192 | * @param string $lang 193 | */ 194 | public function setLang($lang = 'en') { 195 | $this->getConfig()->setLang($lang); 196 | } 197 | 198 | /** 199 | * Get the language 200 | * 201 | * @return string 202 | */ 203 | public function getLang() { 204 | return $this->getConfig()->getLang(); 205 | } 206 | 207 | //------------------------------------------------------------------------------ 208 | // TimeZone 209 | //------------------------------------------------------------------------------ 210 | 211 | /** 212 | * Set the timezone 213 | * By default 'Europe/London' 214 | * 215 | * @param string $timezone 216 | */ 217 | public function setTimeZone($timezone = 'Europe/London') { 218 | $this->getConfig()->setTimeZone($timezone); 219 | } 220 | 221 | /** 222 | * Get the timezone 223 | * 224 | * @return string 225 | */ 226 | public function getTimeZone() { 227 | return $this->getConfig()->getTimeZone(); 228 | } 229 | 230 | //------------------------------------------------------------------------------ 231 | // Adult Content 232 | //------------------------------------------------------------------------------ 233 | 234 | /** 235 | * Set adult content flag 236 | * By default false 237 | * 238 | * @param boolean $adult 239 | */ 240 | public function setAdult($adult = false) { 241 | $this->getConfig()->setAdult($adult); 242 | } 243 | 244 | /** 245 | * Get the adult content flag 246 | * 247 | * @return string 248 | */ 249 | public function getAdult() { 250 | return $this->getConfig()->getAdult(); 251 | } 252 | 253 | //------------------------------------------------------------------------------ 254 | // Debug Mode 255 | //------------------------------------------------------------------------------ 256 | 257 | /** 258 | * Set debug mode 259 | * By default false 260 | * 261 | * @param boolean $debug 262 | */ 263 | public function setDebug($debug = false) { 264 | $this->getConfig()->setDebug($debug); 265 | } 266 | 267 | /** 268 | * Get debug status 269 | * 270 | * @return boolean 271 | */ 272 | public function getDebug() { 273 | return $this->getConfig()->getDebug(); 274 | } 275 | 276 | //------------------------------------------------------------------------------ 277 | // Config 278 | //------------------------------------------------------------------------------ 279 | 280 | /** 281 | * Loads the configuration of the API 282 | * 283 | * @return boolean 284 | */ 285 | private function _loadConfig() { 286 | $this->_apiconfiguration = new APIConfiguration($this->_call('configuration')); 287 | 288 | return ! empty($this->_apiconfiguration); 289 | } 290 | 291 | /** 292 | * Get Configuration of the API (Revisar) 293 | * 294 | * @return Configuration 295 | */ 296 | public function getAPIConfig() { 297 | return $this->_apiconfiguration; 298 | } 299 | 300 | //------------------------------------------------------------------------------ 301 | // Get Variables 302 | //------------------------------------------------------------------------------ 303 | 304 | /** 305 | * Get the URL images 306 | * You can specify the width, by default original 307 | * 308 | * @param String $size A String like 'w185' where you specify the image width 309 | * @return string 310 | */ 311 | public function getImageURL($size = 'original') { 312 | return $this->_apiconfiguration->getImageBaseURL().$size; 313 | } 314 | 315 | //------------------------------------------------------------------------------ 316 | // Get Lists of Discover 317 | //------------------------------------------------------------------------------ 318 | 319 | /** 320 | * Discover Movies 321 | * @add by tnsws 322 | * 323 | * @return Movie[] 324 | */ 325 | public function getDiscoverMovies($page = 1) { 326 | 327 | $movies = array(); 328 | 329 | $result = $this->_call('discover/movie', '&page='. $page); 330 | 331 | foreach($result['results'] as $data){ 332 | $movies[] = new Movie($data); 333 | } 334 | 335 | return $movies; 336 | } 337 | 338 | /** 339 | * Discover TVShows 340 | * @add by tnsws 341 | * 342 | * @return TVShow[] 343 | */ 344 | public function getDiscoverTVShows($page = 1) { 345 | 346 | $tvShows = array(); 347 | 348 | $result = $this->_call('discover/tv', '&page='. $page); 349 | 350 | foreach($result['results'] as $data){ 351 | $tvShows[] = new TVShow($data); 352 | } 353 | 354 | return $tvShows; 355 | } 356 | 357 | //------------------------------------------------------------------------------ 358 | // Get Lists of Discover 359 | //------------------------------------------------------------------------------ 360 | 361 | /** 362 | * Get latest Movie 363 | * @add by tnsws 364 | * 365 | * @return Movie 366 | */ 367 | public function getDiscoverMovie($page = 1) { 368 | 369 | $movies = array(); 370 | 371 | $result = $this->_call('discover/movie', 'page='. $page); 372 | 373 | foreach($result['results'] as $data){ 374 | $movies[] = new Movie($data); 375 | } 376 | 377 | return $movies; 378 | } 379 | 380 | //------------------------------------------------------------------------------ 381 | // Get Featured Movies 382 | //------------------------------------------------------------------------------ 383 | 384 | /** 385 | * Get latest Movie 386 | * 387 | * @return Movie 388 | */ 389 | public function getLatestMovie() { 390 | return new Movie($this->_call('movie/latest')); 391 | } 392 | 393 | /** 394 | * Get Now Playing Movies 395 | * 396 | * @param integer $page 397 | * @return Movie[] 398 | */ 399 | public function getNowPlayingMovies($page = 1) { 400 | 401 | $movies = array(); 402 | 403 | $result = $this->_call('movie/now_playing', '&page='. $page); 404 | 405 | foreach($result['results'] as $data){ 406 | $movies[] = new Movie($data); 407 | } 408 | 409 | return $movies; 410 | } 411 | 412 | /** 413 | * Get Popular Movies 414 | * 415 | * @param integer $page 416 | * @return Movie[] 417 | */ 418 | public function getPopularMovies($page = 1) { 419 | 420 | $movies = array(); 421 | 422 | $result = $this->_call('movie/popular', '&page='. $page); 423 | 424 | foreach($result['results'] as $data){ 425 | $movies[] = new Movie($data); 426 | } 427 | 428 | return $movies; 429 | } 430 | 431 | /** 432 | * Get Top Rated Movies 433 | * @add by tnsws 434 | * 435 | * @param integer $page 436 | * @return Movie[] 437 | */ 438 | public function getTopRatedMovies($page = 1) { 439 | 440 | $movies = array(); 441 | 442 | $result = $this->_call('movie/top_rated', '&page='. $page); 443 | 444 | foreach($result['results'] as $data){ 445 | $movies[] = new Movie($data); 446 | } 447 | 448 | return $movies; 449 | } 450 | 451 | /** 452 | * Get Upcoming Movies 453 | * @add by tnsws 454 | * 455 | * @param integer $page 456 | * @return Movie[] 457 | */ 458 | public function getUpcomingMovies($page = 1) { 459 | 460 | $movies = array(); 461 | 462 | $result = $this->_call('movie/upcoming', '&page='. $page); 463 | 464 | foreach($result['results'] as $data){ 465 | $movies[] = new Movie($data); 466 | } 467 | 468 | return $movies; 469 | } 470 | 471 | //------------------------------------------------------------------------------ 472 | // Get Featured TVShows 473 | //------------------------------------------------------------------------------ 474 | 475 | /** 476 | * Get latest TVShow 477 | * 478 | * @return TVShow 479 | */ 480 | public function getLatestTVShow() { 481 | return new TVShow($this->_call('tv/latest')); 482 | } 483 | 484 | /** 485 | * Get On The Air TVShows 486 | * 487 | * @param integer $page 488 | * @return TVShow[] 489 | */ 490 | public function getOnTheAirTVShows($page = 1) { 491 | 492 | $tvShows = array(); 493 | 494 | $result = $this->_call('tv/on_the_air', '&page='. $page); 495 | 496 | foreach($result['results'] as $data){ 497 | $tvShows[] = new TVShow($data); 498 | } 499 | 500 | return $tvShows; 501 | } 502 | 503 | /** 504 | * Get Airing Today TVShows 505 | * 506 | * @param integer $page 507 | * @param string $timezone 508 | * @return TVShow[] 509 | */ 510 | public function getAiringTodayTVShows($page = 1, $timeZone = null) { 511 | $timeZone = (isset($timeZone)) ? $timeZone : $this->getConfig()->getTimeZone(); 512 | $tvShows = array(); 513 | 514 | $result = $this->_call('tv/airing_today', '&page='. $page); 515 | 516 | foreach($result['results'] as $data){ 517 | $tvShows[] = new TVShow($data); 518 | } 519 | 520 | return $tvShows; 521 | } 522 | 523 | /** 524 | * Get Top Rated TVShows 525 | * 526 | * @param integer $page 527 | * @return TVShow[] 528 | */ 529 | public function getTopRatedTVShows($page = 1) { 530 | 531 | $tvShows = array(); 532 | 533 | $result = $this->_call('tv/top_rated', '&page='. $page); 534 | 535 | foreach($result['results'] as $data){ 536 | $tvShows[] = new TVShow($data); 537 | } 538 | 539 | return $tvShows; 540 | } 541 | 542 | /** 543 | * Get Popular TVShows 544 | * 545 | * @param integer $page 546 | * @return TVShow[] 547 | */ 548 | public function getPopularTVShows($page = 1) { 549 | 550 | $tvShows = array(); 551 | 552 | $result = $this->_call('tv/popular', '&page='. $page); 553 | 554 | foreach($result['results'] as $data){ 555 | $tvShows[] = new TVShow($data); 556 | } 557 | 558 | return $tvShows; 559 | } 560 | 561 | //------------------------------------------------------------------------------ 562 | // Get Featured Persons 563 | //------------------------------------------------------------------------------ 564 | 565 | /** 566 | * Get latest Person 567 | * 568 | * @return Person 569 | */ 570 | public function getLatestPerson() { 571 | return new Person($this->_call('person/latest')); 572 | } 573 | 574 | /** 575 | * Get Popular Persons 576 | * 577 | * @return Person[] 578 | */ 579 | public function getPopularPersons($page = 1) { 580 | $persons = array(); 581 | 582 | $result = $this->_call('person/popular', '&page='. $page); 583 | 584 | foreach($result['results'] as $data){ 585 | $persons[] = new Person($data); 586 | } 587 | 588 | return $persons; 589 | } 590 | 591 | //------------------------------------------------------------------------------ 592 | // API Call 593 | //------------------------------------------------------------------------------ 594 | 595 | /** 596 | * Makes the call to the API and retrieves the data as a JSON 597 | * 598 | * @param string $action API specific function name for in the URL 599 | * @param string $appendToResponse The extra append of the request 600 | * @return string 601 | */ 602 | private function _call($action, $appendToResponse = '') { 603 | 604 | $url = self::_API_URL_.$action .'?api_key='. $this->getConfig()->getAPIKey() .'&language='. $this->getConfig()->getLang() .'&append_to_response='. implode(',', (array) $appendToResponse) .'&include_adult='. $this->getConfig()->getAdult(); 605 | 606 | if ($this->getConfig()->getDebug()) { 607 | echo '
check request
'; 608 | } 609 | 610 | $ch = curl_init(); 611 | curl_setopt($ch, CURLOPT_URL, $url); 612 | curl_setopt($ch, CURLOPT_HEADER, 0); 613 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 614 | curl_setopt($ch, CURLOPT_FAILONERROR, 1); 615 | 616 | $results = curl_exec($ch); 617 | 618 | curl_close($ch); 619 | 620 | return (array) json_decode(($results), true); 621 | } 622 | 623 | //------------------------------------------------------------------------------ 624 | // Get Data Objects 625 | //------------------------------------------------------------------------------ 626 | 627 | /** 628 | * Get a Movie 629 | * 630 | * @param int $idMovie The Movie id 631 | * @param array $appendToResponse The extra append of the request 632 | * @return Movie 633 | */ 634 | public function getMovie($idMovie, $appendToResponse = null) { 635 | $appendToResponse = (isset($appendToResponse)) ? $appendToResponse : $this->getConfig()->getAppender('movie'); 636 | 637 | return new Movie($this->_call('movie/' . $idMovie, $appendToResponse)); 638 | } 639 | 640 | /** 641 | * Get a TVShow 642 | * 643 | * @param int $idTVShow The TVShow id 644 | * @param array $appendToResponse The extra append of the request 645 | * @return TVShow 646 | */ 647 | public function getTVShow($idTVShow, $appendToResponse = null) { 648 | $appendToResponse = (isset($appendToResponse)) ? $appendToResponse : $this->getConfig()->getAppender('tvshow'); 649 | 650 | return new TVShow($this->_call('tv/' . $idTVShow, $appendToResponse)); 651 | } 652 | 653 | /** 654 | * Get a Season 655 | * 656 | * @param int $idTVShow The TVShow id 657 | * @param int $numSeason The Season number 658 | * @param array $appendToResponse The extra append of the request 659 | * @return Season 660 | */ 661 | public function getSeason($idTVShow, $numSeason, $appendToResponse = null) { 662 | $appendToResponse = (isset($appendToResponse)) ? $appendToResponse : $this->getConfig()->getAppender('season'); 663 | 664 | return new Season($this->_call('tv/'. $idTVShow .'/season/' . $numSeason, $appendToResponse), $idTVShow); 665 | } 666 | 667 | /** 668 | * Get a Episode 669 | * 670 | * @param int $idTVShow The TVShow id 671 | * @param int $numSeason The Season number 672 | * @param int $numEpisode the Episode number 673 | * @param array $appendToResponse The extra append of the request 674 | * @return Episode 675 | */ 676 | public function getEpisode($idTVShow, $numSeason, $numEpisode, $appendToResponse = null) { 677 | $appendToResponse = (isset($appendToResponse)) ? $appendToResponse : $this->getConfig()->getAppender('episode'); 678 | 679 | return new Episode($this->_call('tv/'. $idTVShow .'/season/'. $numSeason .'/episode/'. $numEpisode, $appendToResponse), $idTVShow); 680 | } 681 | 682 | /** 683 | * Get a Person 684 | * 685 | * @param int $idPerson The Person id 686 | * @param array $appendToResponse The extra append of the request 687 | * @return Person 688 | */ 689 | public function getPerson($idPerson, $appendToResponse = null) { 690 | $appendToResponse = (isset($appendToResponse)) ? $appendToResponse : $this->getConfig()->getAppender('person'); 691 | 692 | return new Person($this->_call('person/' . $idPerson, $appendToResponse)); 693 | } 694 | 695 | /** 696 | * Get a Collection 697 | * 698 | * @param int $idCollection The Person id 699 | * @param array $appendToResponse The extra append of the request 700 | * @return Collection 701 | */ 702 | public function getCollection($idCollection, $appendToResponse = null) { 703 | $appendToResponse = (isset($appendToResponse)) ? $appendToResponse : $this->getConfig()->getAppender('collection'); 704 | 705 | return new Collection($this->_call('collection/' . $idCollection, $appendToResponse)); 706 | } 707 | 708 | /** 709 | * Get a Company 710 | * 711 | * @param int $idCompany The Person id 712 | * @param array $appendToResponse The extra append of the request 713 | * @return Company 714 | */ 715 | public function getCompany($idCompany, $appendToResponse = null) { 716 | $appendToResponse = (isset($appendToResponse)) ? $appendToResponse : $this->getConfig()->getAppender('company'); 717 | 718 | return new Company($this->_call('company/' . $idCompany, $appendToResponse)); 719 | } 720 | 721 | //------------------------------------------------------------------------------ 722 | // Searches 723 | //------------------------------------------------------------------------------ 724 | 725 | /** 726 | * Multi Search 727 | * 728 | * @param string $searchQuery The query for the search 729 | * @return array[] 730 | */ 731 | public function multiSearch($searchQuery) 732 | { 733 | $searchResults = array( 734 | Movie::MEDIA_TYPE_MOVIE => array(), 735 | TVShow::MEDIA_TYPE_TV => array(), 736 | Person::MEDIA_TYPE_PERSON => array(), 737 | ); 738 | 739 | $result = $this->_call('search/multi', '&query=' . urlencode($searchQuery)); 740 | 741 | if(!array_key_exists('results', $result)){ 742 | return $searchResults; 743 | } 744 | 745 | foreach ($result['results'] as $data) { 746 | if ($data['media_type'] === Movie::MEDIA_TYPE_MOVIE) { 747 | $searchResults[Movie::MEDIA_TYPE_MOVIE][] = new Movie($data); 748 | } elseif ($data['media_type'] === TVShow::MEDIA_TYPE_TV) { 749 | $searchResults[TVShow::MEDIA_TYPE_TV][] = new TvShow($data); 750 | } elseif ($data['media_type'] === Person::MEDIA_TYPE_PERSON) { 751 | $searchResults[Person::MEDIA_TYPE_PERSON][] = new Person($data); 752 | } 753 | } 754 | 755 | return $searchResults; 756 | } 757 | 758 | /** 759 | * Search Movie 760 | * 761 | * @param string $movieTitle The title of a Movie 762 | * @return Movie[] 763 | */ 764 | public function searchMovie($movieTitle){ 765 | 766 | $movies = array(); 767 | 768 | $result = $this->_call('search/movie', '&query='. urlencode($movieTitle)); 769 | 770 | foreach($result['results'] as $data){ 771 | $movies[] = new Movie($data); 772 | } 773 | 774 | return $movies; 775 | } 776 | 777 | /** 778 | * Search TVShow 779 | * 780 | * @param string $tvShowTitle The title of a TVShow 781 | * @return TVShow[] 782 | */ 783 | public function searchTVShow($tvShowTitle){ 784 | 785 | $tvShows = array(); 786 | 787 | $result = $this->_call('search/tv', '&query='. urlencode($tvShowTitle)); 788 | 789 | foreach($result['results'] as $data){ 790 | $tvShows[] = new TVShow($data); 791 | } 792 | 793 | return $tvShows; 794 | } 795 | 796 | /** 797 | * Search Person 798 | * 799 | * @param string $personName The name of the Person 800 | * @return Person[] 801 | */ 802 | public function searchPerson($personName){ 803 | 804 | $persons = array(); 805 | 806 | $result = $this->_call('search/person', '&query='. urlencode($personName)); 807 | 808 | foreach($result['results'] as $data){ 809 | $persons[] = new Person($data); 810 | } 811 | 812 | return $persons; 813 | } 814 | 815 | /** 816 | * Search Collection 817 | * 818 | * @param string $collectionName The name of the Collection 819 | * @return Collection[] 820 | */ 821 | public function searchCollection($collectionName){ 822 | 823 | $collections = array(); 824 | 825 | $result = $this->_call('search/collection', '&query='. urlencode($collectionName)); 826 | 827 | foreach($result['results'] as $data){ 828 | $collections[] = new Collection($data); 829 | } 830 | 831 | return $collections; 832 | } 833 | 834 | /** 835 | * Search Company 836 | * 837 | * @param string $companyName The name of the Company 838 | * @return Company[] 839 | */ 840 | public function searchCompany($companyName){ 841 | 842 | $companies = array(); 843 | 844 | $result = $this->_call('search/company', '&query='. urlencode($companyName)); 845 | 846 | foreach($result['results'] as $data){ 847 | $companies[] = new Company($data); 848 | } 849 | 850 | return $companies; 851 | } 852 | 853 | //------------------------------------------------------------------------------ 854 | // Find 855 | //------------------------------------------------------------------------------ 856 | 857 | /** 858 | * Find 859 | * 860 | * @param string $companyName The name of the Company 861 | * @return array 862 | */ 863 | public function find($id, $external_source = 'imdb_id'){ 864 | 865 | $found = array(); 866 | 867 | $result = $this->_call('find/'.$id, '&external_source='. urlencode($external_source)); 868 | 869 | foreach($result['movie_results'] as $data){ 870 | $found['movies'][] = new Movie($data); 871 | } 872 | foreach($result['person_results'] as $data){ 873 | $found['persons'][] = new Person($data); 874 | } 875 | foreach($result['tv_results'] as $data){ 876 | $found['tvshows'][] = new TVShow($data); 877 | } 878 | foreach($result['tv_season_results'] as $data){ 879 | $found['seasons'][] = new Season($data); 880 | } 881 | foreach($result['tv_episode_results'] as $data){ 882 | $found['episodes'][] = new Episode($data); 883 | } 884 | 885 | return $found; 886 | } 887 | 888 | //------------------------------------------------------------------------------ 889 | // API Extra Info 890 | //------------------------------------------------------------------------------ 891 | 892 | /** 893 | * Get Timezones 894 | * 895 | * @return array 896 | */ 897 | public function getTimezones() { 898 | return $this->_call('timezones/list'); 899 | } 900 | 901 | /** 902 | * Get Jobs 903 | * 904 | * @return array 905 | */ 906 | public function getJobs() { 907 | return $this->_call('job/list'); 908 | } 909 | 910 | /** 911 | * Get Movie Genres 912 | * 913 | * @return Genre[] 914 | */ 915 | public function getMovieGenres() { 916 | 917 | $genres = array(); 918 | 919 | $result = $this->_call('genre/movie/list'); 920 | 921 | foreach($result['genres'] as $data){ 922 | $genres[] = new Genre($data); 923 | } 924 | 925 | return $genres; 926 | } 927 | 928 | /** 929 | * Get TV Genres 930 | * 931 | * @return Genre[] 932 | */ 933 | public function getTVGenres() { 934 | 935 | $genres = array(); 936 | 937 | $result = $this->_call('genre/tv/list'); 938 | 939 | foreach($result['genres'] as $data){ 940 | $genres[] = new Genre($data); 941 | } 942 | 943 | return $genres; 944 | } 945 | 946 | //------------------------------------------------------------------------------ 947 | // Genre 948 | //------------------------------------------------------------------------------ 949 | 950 | /** 951 | * Get Movies by Genre 952 | * 953 | * @param integer $idGenre 954 | * @param integer $page 955 | * @return Movie[] 956 | */ 957 | public function getMoviesByGenre($idGenre, $page = 1) { 958 | 959 | $movies = array(); 960 | 961 | $result = $this->_call('genre/'.$idGenre.'/movies', '&page='. $page); 962 | 963 | foreach($result['results'] as $data){ 964 | $movies[] = new Movie($data); 965 | } 966 | 967 | return $movies; 968 | } 969 | } 970 | ?> 971 | --------------------------------------------------------------------------------