Skip to content

VdoCipher/php-playback-token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vdocipher/playback-token

VdoCipher playback token generator.

Install

composer require vdocipher/playback-token

Requires PHP 8.0+.

Quick start

use VdoCipher\Playback;

$pb = new Playback($apiKey, [
    'apiKeyId' => 'your-api-key-id',
    'videoId'  => '1234567890abcdef1234567890abcdef',
    'userId'   => '27083',
]);

$token = $pb->getToken();
// Use $token in your VdoCipher player URL.

Error handling

getToken() throws VdoCipher\PlaybackException (extends \InvalidArgumentException) on the first validation error. Catch it where you can produce a useful response — typically your controller or job handler:

use VdoCipher\Playback;
use VdoCipher\PlaybackException;

try {
    $token = (new Playback($apiKey, $payload))->getToken();
} catch (PlaybackException $e) {
    error_log('VdoCipher token error: ' . $e->getMessage());
    http_response_code(400);
    return;
}

API

Method Returns Notes
new Playback(?string $apiKey, ?array $data) Either arg may be null; errors surface from getToken().
setKey(?string $key) void Replace the API key. Null clears it.
setPayload(?array $data) void Replace the payload. Null clears it.
getToken() string Token string on success. Throws VdoCipher\PlaybackException on the first error encountered.

Payload fields

Key Required Type Notes
apiKeyId yes string Ensure this stays secret on your server.
videoId yes string 32-char lowercase hex.
policyId no string If not specified, default policy is applied.
userId no string 1–36 chars, [a-z0-9_-].
ip no string Can lock the token to specific IP address.
watermarkValues no string[] Array of watermark substitution values.

License

MIT Copyright (c) 2026 VdoCipher Media Solutions Pvt Ltd

The MIT license covers this SDK's source code. Use of the VdoCipher service is governed by the VdoCipher Terms of Service.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages