1. Go to this page and download the library: Download havenstd06/laravel-plex 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/ */
havenstd06 / laravel-plex example snippets
return [
'server_url' => env('PLEX_SERVER_URL', ''), // Plex Server URL (ex: http://[IP address]:32400)
'token' => env('PLEX_TOKEN', ''),
'client_identifier' => env('PLEX_CLIENT_IDENTIFIER', ''), // (UUID, serial number, or other number unique per device)
'product' => env('PLEX_PRODUCT', 'havenstd06/laravel-plex'), // (Plex application name, eg Laika, Plex Media Server, Media Link)
'version' => env('PLEX_VERSION', '1.0.0'), // (Plex application version number)
'validate_ssl' => env('PLEX_VALIDATE_SSL', true), // Validate SSL when creating api client.
];
use Havenstd06\LaravelPlex\Services\Plex as PlexClient;
$provider = new PlexClient;
$data = [
'auth' => [
'username/email', // Required
'password', // Required
],
'headers' => [
// Headers: https://github.com/Arcanemagus/plex-api/wiki/Plex.tv#request-headers
// X-Plex-Client-Identifier is already defined in default config file
]
];
// The second parameter allows you to choose if you want to
// authenticate with the token registered in the config
// (ONLY IF THE TOKEN EXISTS).
$plexUser = $provider->signIn($data, false);
$token = $plexUser['user']['authToken'];