Skip to content

Commit

Permalink
Adding the Discover API
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Jan 18, 2014
1 parent 07e8235 commit 811b68c
Show file tree
Hide file tree
Showing 9 changed files with 623 additions and 129 deletions.
30 changes: 30 additions & 0 deletions examples/discover/model/movies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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);

$query = new \Tmdb\Model\Query\Discover\DiscoverMoviesQuery();

$query
->page(1)
->language('en')
;

$repository = new \Tmdb\Repository\DiscoverRepository($client);
$response = $repository->discoverMovies($query);

var_dump($response);

30 changes: 30 additions & 0 deletions examples/discover/model/tv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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);

$query = new \Tmdb\Model\Query\Discover\DiscoverTvQuery();

$query
->page(1)
->language('en')
;

$repository = new \Tmdb\Repository\DiscoverRepository($client);
$response = $repository->discoverTv($query);

var_dump($response);

12 changes: 12 additions & 0 deletions lib/Tmdb/Api/Discover.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,16 @@ public function discoverMovies(array $options = array(), array $headers = array(
{
return $this->get('discover/movie', $options, $headers);
}

/**
* Discover TV shows by different types of data like average rating, number of votes, genres, the network they aired on and air dates.
*
* @param array $options
* @param array $headers
* @return mixed
*/
public function discoverTv(array $options = array(), array $headers = array())
{
return $this->get('discover/tv', $options, $headers);
}
}
4 changes: 4 additions & 0 deletions lib/Tmdb/Factory/TvFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public static function createCollection(array $data = array())
{
$collection = new GenericCollection();

if (array_key_exists('results', $data)) {
$data = $data['results'];
}

foreach($data as $item) {
$collection->add(null, self::create($item));
}
Expand Down
43 changes: 0 additions & 43 deletions lib/Tmdb/Model/Query/AbstractQuery.php

This file was deleted.

86 changes: 0 additions & 86 deletions lib/Tmdb/Model/Query/Discover.php

This file was deleted.

Loading

0 comments on commit 811b68c

Please sign in to comment.