Update 5 June 2018 This implementation of VdoCipher Secure Streaming API is updated for latest API version v3, and for latest player version 1.6.4. A previous version of the blog used API v2. While we still support API version v2 we recommend that you use API v3 as part of your video workflow. If you have any queries regarding API v2 please do get in touch with us at support@vdocipher.com. The complete VdoCipher API reference is available here. A sample video-based workflow for your website is suggested here.
Here is a PHP code to use VdoCipher API along with dynamic watermarking. You need to pass the video ID to the vdo_embed function in embed_code.php
and the your API secret key to the $api_key
variable in vdo_embed.php
. The code should work out of the box after editing the details. The sample code is so structured that you only need to add vdo_embed.php
once to your file system, and enter the embed code given in embed_code.php
at each instance of video player.
https://gist.github.com/milangupta4/e171ab540f949d64ab07244236dacfab
The structure of annotation JSON is described in the link : Add text to videos with watermark. To add user details you can create a $userdetail
variable which will collect user-identifiable information such as name and email address from your website database, and append it to the watermark.
PHP Sample code to get OTP
In this example, the sample videoID is 1234567890, and the API Secret Key is a1b2c3d4e5. The time-to-live for OTP validity is set to 300s in the sample code. You can reference the API documentation for more info.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://dev.vdocipher.com/api/videos/1234567890/otp",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
"ttl" => 300,
]),
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Authorization: Apisecret a1b2c3d4e5",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
FAQs
How to protect your videos on the PHP backend?
The security integration of video streaming, like multi-DRM, is not directly available for PHP use. The easiest solution would be to use a secure video streaming service provider like VdoCipher and integrate with their APIs compatible with the PHP backend.
How to secure API in PHP?
API gets used as a documented method of interacting with other services, and that is why there is no exact answer to the question, but applying OAuth and using a shared secret along with the request made can work as generic solutions.
Is PHP vulnerable to Video Security lapses?
No, it has nothing to do with video security, as videos get secured through cloud encoding and global distribution via a dynamic key exchange mechanism.
Supercharge Your Business with Videos
At VdoCipher we maintain the strongest content protection for videos. We also deliver the best viewer experience with brand friendly customisations. We'd love to hear from you, and help boost your video streaming business.
Leave a Reply