PHP code example of rooxie / omdb

1. Go to this page and download the library: Download rooxie/omdb library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rooxie / omdb example snippets


$omdb = new Rooxie\OMDb(
    new \GuzzleHttp\Client(),
    new \GuzzleHttp\Psr7\HttpFactory(),
    'your-api-key'
);

$movie = $omdb->getByImdbId('tt0110912');
// {"Title":"Pulp Fiction","Year":"1994","Rated":"R","Released":"14 Oct 1994" ...
echo $movie->getBody()->getContents();

$movie = $omdb->getByTitle('harry potter', \Rooxie\Enum\TitleType::MOVIE, 2004);
// {"Title":"Harry Potter and the Prisoner of Azkaban","Year":"2004","Rated":"PG","Released":"04 Jun 2004" ...
echo $movie->getBody()->getContents();

$movies = $omdb->search('arrival', \Rooxie\Enum\TitleType::MOVIE, 2016, 1)->getBody()->getContents();
print_r(json_decode($movies, true));