Closed kurtaking closed 8 years ago
Hi Kurt,
You can find most of the examples in the php-tmdb/api repository. In this case you should take a look at the search movie example.
The example shows the following,
$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);
$result = $client->getSearchApi()->searchMovies('batman');
Since this package includes a facade you don't have to do the setup with the API key, instead you can write,
$results = Tmdb::getSearchApi()->searchMovies('batman');
Another way to do this is to use repositories, see search/model/movie.php which shows,
$token = new \Tmdb\ApiToken(TMDB_API_KEY);
$client = new \Tmdb\Client($token);
$query = new \Tmdb\Model\Search\SearchQuery\MovieSearchQuery();
$query->page(1);
$repository = new \Tmdb\Repository\SearchRepository($client);
$find = $repository->searchMovie('batman', $query);
Again we may use some of Laravel's magic to help construct the objects,
// Get the Movie and Search repositories from the service container
$query = App::make(\Tmdb\Model\Search\SearchQuery\MovieSearchQuery::class);
$repository = App::make(\Tmdb\Repository\SearchRepository::class);
// Search for batman and return the first page
$query->page(1);
$find = $repository->searchMovie('batman', $query);
Thank you! That worked perfectly.
Where can I find examples/documentation on all the default functions?
For example Tmdb::getMoviesApi()->getMovie($id);
How can I search for one/all movies by a specific title?
Thanks!