PHP code example of r11baka / omdb

1. Go to this page and download the library: Download r11baka/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/ */

    

r11baka / omdb example snippets



use Omdb\Omdb;

$omdb = new Omdb($API_KEY);
$response = $omdb->search("The Matrix");
var_dump($response);

var_dump($response[0]->getImdbId());
var_dump($response[0]->getTitle());
var_dump($response[0]->getType());

array(1) {
  [0] =>
  class Omdb\Api\Response\SearchResult#8 (5) {
    private string $title =>
    string(10) "The Matrix"
    private int $year =>
    int(1999)
    private string $imdbId =>
    string(9) "tt0133093"
    private string $type =>
    string(5) "movie"
    private string $poster =>
    string(138) "https://m.media-amazon.com/images/M/MV5BNzQzOTk3OTAtNDQ0Zi00ZTVkLWI0MTEtMDllZjNkYzNjNTc4L2ltYWdlXkEyXkFqcGdeQXVyNjU0OTQ0OTY@._V1_SX300.jpg"
  }
}


use Omdb\Omdb;

$omdb = new Omdb($API_KEY);
$response = $omdb->search(['title' => 'Matrix','take' => 20]);
var_dump($response);


use Omdb\Omdb;

$omdb = new Omdb($API_KEY);
$result = $omdb->title("The Matrix")->search();

// etc
echo $result->getTitle();
echo $result->getImdbID();


use Omdb\Omdb;

$omdb = new Omdb($API_KEY);
$result = $omdb->title("The Matrix")->year(1999)->search();


use Omdb\Omdb;

$omdb = new Omdb($API_KEY);
$result = $omdb->imdb('tt0133093')->search();