1. Go to this page and download the library: Download joserick/phplex 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/ */
joserick / phplex example snippets
// include composer autoload
use Joserick\PHPlex\Plex;
// build plex object with you account data.
$plex = new Plex('username', 'password', 'address');
// to finally create server instances
$server = $plex->getServer();
$servers = array(
'my_server' => array( // Name with which you want to identify the configuration of the server.
'username' => 'username|email', // Username or email of the plex.tv account.
'password' => 'password' // Password of the plex.tv account.
'address' => '192.168.11.9', // Ip of the server, default localhost.
'port' => '32401' // Ip port, default 32400.
'token' => '********' // Connexion token, default phplex generate one.
),
// ...
);
$plex = new Plex();
$plex->registerServers($servers);
$server = $plex->getServer('my_server');
// First get a section of type movie.
$section = $server->getLibrary()->getSection('Movies');
$movies = $section->getUnwatched();
foreach ($movies as $movie){
echo $movie->getTitle();
}
$clients = $plex->getAllClients();
foreach ($clients as $client){
echo $client->getName();
}
// Get a client specific.
$client_version = $plex->getClient('Chrome')->version;