PHP code example of ngsoft / emby-client-php

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

    

ngsoft / emby-client-php example snippets




use EmbyClient\Connection;
use EmbyClient\EmbyConnect;
use EmbyClient\Cache;
use EmbyClient\HttpClient;

// if you are using a custom cache library you can add that line
// if you installed symfony/cache you don't need that line
Cache::setCachePool($myCacheItemPoolInstance);
// if you are using a custom Http Client you can add that line
// with guzzle it is automatic
HttpClient::setHttpClient($myHttpClientInstance);
// To make a connection using emby connect:
$connection = EmbyConnect::connect('usernameOrEmail', 'password', 'serverName');
// or to make a connection to a local or remote server using its ip or address using an api key
// you can generate an api key for your server in the web interface of your emby server:
// settings -> Advanced -> Api Keys -> New Api Key
$connection = Connection::getConnection('ipAddressOrHostname', 'api_key');
// or with custom port 
$connection = Connection::getConnection('ipAddressOrHostname:port', 'api_key');
// you can also connect to a server using its http(s) address and port
$connection = Connection::getConnection('https://example.com:8096', 'api_key');

// you can also test if a connection is authenticated
if($connection->testConnection())
{
    // you can also make a connection active globally
    // the first to connect is automatically registered
    $connection->makeActive();
}


use EmbyClient\ApiClient;

$devices = ApiClient::getDevices();



use EmbyClient\Model\Services\DeviceService;

$service = new DeviceService($connection)

$devices = $service->getDevices();

shell
composer