Skip to content

Commit

Permalink
Adding some more examples for people and fixing some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 26, 2014
1 parent 6078fbe commit 7a8405d
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 7 deletions.
22 changes: 22 additions & 0 deletions examples/people/model/external_ids.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);

$repository = new \Tmdb\Repository\PeopleRepository($client);
$externalIds = $repository->getExternalIds(287);

var_dump($externalIds);
22 changes: 22 additions & 0 deletions examples/people/model/latest.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);

$repository = new \Tmdb\Repository\PeopleRepository($client);
$latest = $repository->getLatest();

var_dump($latest);
22 changes: 22 additions & 0 deletions examples/people/model/popular.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);

$repository = new \Tmdb\Repository\PeopleRepository($client);
$popular = $repository->getPopular();

var_dump($popular);
19 changes: 15 additions & 4 deletions lib/Tmdb/Api/People.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ public function getChanges($person_id, array $parameters = array(), array $heade
return $this->get('person/' . $person_id . '/changes', $parameters, $headers);
}

/**
* Get the external ids for a specific person id.
*
* @param $person_id
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getExternalIds($person_id, array $parameters = array(), array $headers = array())
{
return $this->get('person/' . $person_id . '/external_ids', $parameters, $headers);
}

/**
* Get the list of popular people on The Movie Database. This list refreshes every day.
*
Expand All @@ -138,12 +151,10 @@ public function getPopular(array $parameters = array(), array $headers = array()
/**
* Get the latest person id.
*
* @param array $parameters
* @param array $headers
* @return mixed
*/
public function getLatest(array $parameters = array(), array $headers = array())
public function getLatest()
{
return $this->get('person/latest', $parameters, $headers);
return $this->get('person/latest');
}
}
8 changes: 5 additions & 3 deletions lib/Tmdb/Repository/PeopleRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function getCombinedCredits($id, array $parameters = array(), array $head
*/
public function getExternalIds($id)
{
$data = $this->getApi()->getCombinedCredits($id);
$data = $this->getApi()->getExternalIds($id);
$person = $this->getFactory()->create(array('external_ids' => $data));

return $person->getExternalIds();
Expand Down Expand Up @@ -161,11 +161,13 @@ public function getChanges($id, array $parameters = array(), array $headers = ar
*
* This list refreshes every day.
*
* @param array $parameters
* @param array $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getPopular()
public function getPopular(array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getPopular();
$data = $this->getApi()->getPopular($parameters, $headers);
return $this->getFactory()->createResultCollection($data);
}

Expand Down

0 comments on commit 7a8405d

Please sign in to comment.