From 729eb7c6fbf0de73d65e621c418c1d6e47a3bb8b Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Sat, 2 Nov 2013 04:38:39 +0100 Subject: [PATCH] Adding some examples and a base apikey.php file to run the examples. --- .gitignore | 2 +- apikey.php | 2 ++ examples/changes/model/get.php | 22 +++++++++++++++++ examples/genres/model/get.php | 21 ++++++++++++++++ examples/movies/api/images.php | 19 ++++++++++++++ examples/movies/model/get.php | 45 ++++++++++++++++++++++++++++++++++ examples/people/model/get.php | 19 ++++++++++++++ 7 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 apikey.php create mode 100644 examples/changes/model/get.php create mode 100644 examples/genres/model/get.php create mode 100644 examples/movies/api/images.php create mode 100644 examples/movies/model/get.php create mode 100644 examples/people/model/get.php diff --git a/.gitignore b/.gitignore index 50742799..df16b3c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /vendor/ /composer.lock /*.php +!/apikey.php /.idea/ -/examples/ \ No newline at end of file diff --git a/apikey.php b/apikey.php new file mode 100644 index 00000000..f8072bfb --- /dev/null +++ b/apikey.php @@ -0,0 +1,2 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once('../../../vendor/autoload.php'); +require_once('../../../apikey.php'); + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$changes = new \Tmdb\Model\Changes($client); + +$response = $changes->page(2)->execute(); + diff --git a/examples/genres/model/get.php b/examples/genres/model/get.php new file mode 100644 index 00000000..5c490164 --- /dev/null +++ b/examples/genres/model/get.php @@ -0,0 +1,21 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once('../../../vendor/autoload.php'); +require_once('../../../apikey.php'); + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$genre = \Tmdb\Model\Genre::load($client, 28); + +echo $genre->getName(); \ No newline at end of file diff --git a/examples/movies/api/images.php b/examples/movies/api/images.php new file mode 100644 index 00000000..9e9092df --- /dev/null +++ b/examples/movies/api/images.php @@ -0,0 +1,19 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once('vendor/autoload.php'); +require_once('../../../apikey.php'); + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$images = $client->api('movies')->getImages(550); \ No newline at end of file diff --git a/examples/movies/model/get.php b/examples/movies/model/get.php new file mode 100644 index 00000000..add85015 --- /dev/null +++ b/examples/movies/model/get.php @@ -0,0 +1,45 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ + require_once('../../../vendor/autoload.php'); + require_once('../../../apikey.php'); + + $token = new \Tmdb\ApiToken(TMDB_API_KEY); + $client = new \Tmdb\Client($token); + + $movie = \Tmdb\Model\Movie::load($client, 87421, array( + 'append_to_response' => 'casts,images' + )); + + echo $movie->getTitle() . "\n"; + + echo "Cast\n"; + + foreach($movie->getCast() as $person) { + printf(" - %s as %s\n", $person->getName(), $person->getCharacter()); + } + + foreach($movie->getCrew() as $person) { + printf(" - %s as %s\n", $person->getName(), $person->getJob()); + } + + echo "Images\n"; + + foreach($movie->getImages() as $image) { + printf(" - %s\n", $image->getFilePath()); + } + + echo "Genres\n"; + + foreach($movie->getGenres() as $genre) { + printf(" - %s\n", $genre->getName()); + } \ No newline at end of file diff --git a/examples/people/model/get.php b/examples/people/model/get.php new file mode 100644 index 00000000..6224f7f3 --- /dev/null +++ b/examples/people/model/get.php @@ -0,0 +1,19 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once('../../../vendor/autoload.php'); +require_once('../../../apikey.php'); + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$person = \Tmdb\Model\Person::load($client, 287, array('append_to_response' => 'images'));