PHP code example of immucahit / omdbapi

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

    

immucahit / omdbapi example snippets




use OMDBAPI\Parameters\TitleParameter;
use OMDBAPI\Type;
use OMDBAPI\Plot;
use OMDBAPI\Client;
use OMDBAPI\Models\Model;

$titleParameter = new TitleParameter();
$titleParameter->setTitle('V for Vendetta');
$titleParameter->setYear(2005);
$titleParameter->setType(Type::MOVIE);
$titleParameter->setPlot(Plot::SHORT);

$url = 'http://www.omdbapi.com/';
$apiKey = 'API_KEY';

$client = new Client($url,$apiKey);

$arrayResult = $client->get($titleParameter);
$model = new Model($arrayResult);



use OMDBAPI\Parameters\IDParameter;
use OMDBAPI\Plot;
use OMDBAPI\Client;

$idParameter = new IDParameter();
$idParameter->setId('tt0434409');
$idParameter->setPlot(Plot::SHORT);

$url = 'http://www.omdbapi.com/';
$apiKey = 'API_KEY';

$client = new Client($url,$apiKey);

$arrayResult = $client->get($idParameter);
$model = new Model($arrayResult);



use OMDBAPI\Parameters\SearchParameter;
use OMDBAPI\Type;
use OMDBAPI\Client;

$searchParameter = new SearchParameter();
$searchParameter->setType(Type::MOVIE);
$searchParameter->setKeyword('avengers');

$url = 'http://www.omdbapi.com/';
$apiKey = 'API_KEY';

$client = new Client($url,$apiKey);

$arrayResult = $client->get($searchParameter);