├── .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 | [](https://pixelead0.github.io/tmdb_v3-PHP-API-/index.html)
4 |
5 | [](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 '