PHP code example of vdo / token-creator

1. Go to this page and download the library: Download vdo/token-creator 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/ */

    

vdo / token-creator example snippets




ple 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', '[email protected]'], // 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;