vdo / token-creator
此包提供了生成用于视频播放的jwt令牌的方法
1.4
2024-02-28 08:26 UTC
Requires
- google/protobuf: ^3.25
Requires (Dev)
- protobuf-php/protobuf: ^0.1.3
- protobuf-php/protobuf-plugin: ^0.1.3
README
以下包提供了生成用于视频播放的令牌的功能。您可以在这里了解更多关于vdocipher令牌的信息。
安装包
composer require vdocipher/token-creator
示例代码
<?php require_once __DIR__.'/vendor/autoload.php'; // Path to vendor/autoload.php # Sample Payload $apiKey = 'abcdef1234567890xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // API Key $videoId = '0989fbb847ed4cb1xxxxxxxxxxxxxxxx'; // video id $policyId = 'b703f02b-xxxx-xxxx-xxxx-xxxxxxxxxxxx'; // policy id $payload = [ 'apiKeyId' => substr($apiKey, 0, 16), // only first 16 char of API key 'videoId' => $videoId, // video id // 'policyId' => $policyId, // optional parameter // 'ip' => $ip, // optional parameter // 'userId' => $userId, // optional parameter // 'watermarkValues' => ['John', 'john@xyz.com'], // optional parameter 'iat' => time(), ]; // Important!!! PASS THE FULL API KEY HERE ALONG WITH THE PAYLOAD $vdocipher = new \Vdocipher\Playback($apiKey, $payload); $token = $vdocipher->getToken(); // playback token $uniqueId = 'u'.rand(); $paybackUrl = "https://player.vdocipher.com/v2/?token=$token&videoId=$videoId"; $iframe = '<iframe id="'.$uniqueId.'" src="'.$paybackUrl.'" allowfullscreen allow="encrypted-media" style="height:1280px;width:720px;max-width:100%;border:0;display:block;" ></iframe>'; // iframe echo $iframe;
快乐编码...