Skip to content

Commit

Permalink
Adding some examples and a base apikey.php file to run the examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Nov 2, 2013
1 parent 74aa949 commit 729eb7c
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/vendor/
/composer.lock
/*.php
!/apikey.php
/.idea/
/examples/
2 changes: 2 additions & 0 deletions apikey.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
define('TMDB_API_KEY', 'XXX');
22 changes: 22 additions & 0 deletions examples/changes/model/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @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();

21 changes: 21 additions & 0 deletions examples/genres/model/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @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();
19 changes: 19 additions & 0 deletions examples/movies/api/images.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @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);
45 changes: 45 additions & 0 deletions examples/movies/model/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @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());
}
19 changes: 19 additions & 0 deletions examples/people/model/get.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* This file is part of the Tmdb PHP API created by Michael Roterman.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Tmdb
* @author Michael Roterman <[email protected]>
* @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'));

0 comments on commit 729eb7c

Please sign in to comment.