PHP code example of nordicscreen / q-play-api-client
1. Go to this page and download the library: Download nordicscreen/q-play-api-client 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/ */
nordicscreen / q-play-api-client example snippets
use QPlay\Api\Client\QPlayClient;
$api = new QPlayClient(
apiEndpoint: 'https://your-qplay-host.tld/api/rest',
clientId: 'your-client-id',
clientSecret:'your-client-secret',
scopes: ['media:read', 'media:write'] // optional; provide only the scopes you need
);
// Example: list media items
$mediaList = $api->media()->list(['page' => 1, 'per_page' => 25]);
// Example: get a single media item
$media = $api->media()->getById(123);
// Example: create/update/delete (payload depends on your Q-Play API contract)
//$created = $api->media()->create(['name' => 'My file', ...]);
//$updated = $api->media()->update(123, ['name' => 'Renamed']);
//$api->media()->deleteById(123);
use QPlay\Api\Client\QPlayClient;
use Symfony\Component\Cache\Adapter\FilesystemAdapter; // or any PSR-6 cache
$cache = new FilesystemAdapter(namespace: 'qplay', defaultLifetime: 0);
$tokenItem = $cache->getItem('oauth_access_token');
$api = new QPlayClient(
apiEndpoint: 'https://your-qplay-host.tld/api/rest',
clientId: 'your-client-id',
clientSecret:'your-client-secret',
scopes: ['media:read'],
tokenCacheItem: $tokenItem
);
use GuzzleHttp\Client as GuzzleClient;
use QPlay\Api\Client\QPlayClient;
$guzzle = new GuzzleClient([
'timeout' => 10.0,
// 'proxy' => 'http://proxy:8080',
// 'verify' => '/path/to/ca.pem',
]);
$api = new QPlayClient(
apiEndpoint: 'https://your-qplay-host.tld/api/rest',
clientId: 'your-client-id',
clientSecret:'your-client-secret',
scopes: [],
tokenCacheItem: null,
httpClient: $guzzle
);