PHP code example of onursimsek / opensubtitles-api
1. Go to this page and download the library: Download onursimsek/opensubtitles-api 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/ */
onursimsek / opensubtitles-api example snippets
php
$client = new OpenSubtitles();
php
// Login
$auth = $client->authentication->login(['username' => $username, 'password' => $password]);
// You can use short way
// $client->login($username, $password);
// Logout
$client->authentication->logout($auth->token);
php
// Find subtitles (for all parameters: https://opensubtitles.stoplight.io/docs/opensubtitles-api/open_api.json/paths/~1api~1v1~1subtitles/get)
$subtitles = $client->find([
'id' => '',
'query' => '',
'imdb_id' => '',
...
]);
foreach ($subtitles->data as $subtitle) {
echo $subtitle->id . PHP_EOL;
echo $subtitle->attributes->language . PHP_EOL;
echo $subtitle->attributes->feature_details->title . PHP_EOL;
echo $subtitle->attributes->files[0]->file_id . PHP_EOL;
}
// Find subtitles by title
$subtitles = $client->subtitle->findByTitle('How i met your mother');
// Find subtitles by movie hash
$hash = (new \OpenSubtitles\Hash())->make(__DIR__ . '/../breakdance.avi');
$subtitles = $client->subtitle->findByMovieHash($hash);