File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 22
33A package to retrieve movies and TV information from IMDB using the API at omdbapi.com
44
5+ Now that OMDB requires an API key you can set it using:
6+
7+ ``` php
8+ Imdb::setApiKey('xxx');
9+ ```
10+
511Retrieve full movie details, if you know the name or ID of the movie:
612
713``` php
Original file line number Diff line number Diff line change 1818 ],
1919 "require" : {
2020 "php" : " >=5.4" ,
21- "jleagle/curl-wrapper" : " ~0.1 "
21+ "jleagle/curl-wrapper" : " ~1.0.0 "
2222 },
2323 "require-dev" : {
24- "phpunit/phpunit" : " ~5.0 "
24+ "phpunit/phpunit" : " ~6.3.1 "
2525 },
2626 "autoload" : {
2727 "psr-4" : {
Original file line number Diff line number Diff line change @@ -12,6 +12,13 @@ class Imdb
1212 const TYPE_MOVIE = 'movie ' ;
1313 const TYPE_SERIES = 'series ' ;
1414 const TYPE_EPISODE = 'episode ' ;
15+
16+ protected static $ _apiKey ;
17+
18+ public static function setApiKey ($ apiKey )
19+ {
20+ self ::$ _apiKey = $ apiKey ;
21+ }
1522
1623 /**
1724 * @param string $movie
@@ -125,10 +132,16 @@ protected static function isValidId($string)
125132 */
126133 protected static function _get ($ params )
127134 {
135+ if (!self ::$ _apiKey )
136+ {
137+ throw new ImdbException ('OMDB now requires an API key ' );
138+ }
139+
128140 $ params = array_filter ($ params );
129141
130142 $ params ['r ' ] = 'json ' ;
131143 $ params ['v ' ] = '1 ' ;
144+ $ params ['apikey ' ] = self ::$ _apiKey ;
132145
133146 try
134147 {
You can’t perform that action at this time.
0 commit comments