VdoCipher playback token generator.
composer require vdocipher/playback-tokenRequires PHP 8.0+.
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.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;
}| 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. |
| 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. |
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.