php video api Archives - VdoCipher Blog Secure Video Streaming Sun, 08 Oct 2023 16:27:02 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.5 https://www.vdocipher.com/blog/wp-content/uploads/2016/11/cropped-VdoCipher-logo2-32x32.png php video api Archives - VdoCipher Blog 32 32 Redirected: PHP sample video upload from browser to VdoCipher https://www.vdocipher.com/blog/2016/03/php-sample-video-upload-from-browser-to-vdocipher/ https://www.vdocipher.com/blog/2016/03/php-sample-video-upload-from-browser-to-vdocipher/#respond Sun, 02 Oct 2022 08:37:43 +0000 https://www.vdocipher.com/blog/?p=450 [This article is based on API v2 as documented here.] The Upload API workflow and overview can be found here. Please find below a sample code for enabling video upload from your PHP website’s users. Note that this is sample code and you will need to configure it according to the controller-view structure in your application. It […]

The post Redirected: PHP sample video upload from browser to VdoCipher appeared first on VdoCipher Blog.

]]>
here.]

The Upload API workflow and overview can be found here.

Please find below a sample code for enabling video upload from your PHP website’s users. Note that this is sample code and you will need to configure it according to the controller-view structure in your application. It is not a recommended to put Controller logic and HTML output in a single file.

https://gist.github.com/vibhavsinha/71d394132a98c049f8aa

<?php
function send($action, $params, $posts = false){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $getData = http_build_query($params);
	$postData = ['clientSecretKey'=>'CLIENT_SECRET_KEY'];            ////Replace the caps CLIENT_SECRET_KEY with your video id.
    if ($posts) {
		$postData = http_build_query(array_merge($postData, $posts));
	}
    curl_setopt($curl, CURLOPT_POST, true); 
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
    $url = "http://api.vdocipher.com/v2/$action/?$getData";
    curl_setopt($curl, CURLOPT_URL,$url);
    $html = curl_exec($curl);
    curl_close($curl);
    return $html;
}

$upload_data = json_decode(send('uploadPolicy', [], ['title'=>'NEW_TITLE']), true);
if (is_null($upload_data)) {
	throw new Exception('Exception: ' . $upload_data);
}
?>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  </head>
  <body>

  <form action="<?= $upload_data['upload_link_secure'] ?>" method="post" enctype="multipart/form-data">
    Key to upload: 
	<input type="hidden"  name="key" value="<?= $upload_data['key'] ?>" /><br />
	<input type="hidden" name="success_action_status" value="201" />
	<input type="hidden" name="success_action_redirect" value="https://www.vdocipher.com" />

	<input type="hidden"   name="X-Amz-Credential" value="<?= $upload_data['x-amz-credential'] ?>" />
	<input type="hidden"   name="X-Amz-Algorithm" value="<?= $upload_data['x-amz-algorithm'] ?>" />
	<input type="hidden"   name="X-Amz-Date" value="<?= $upload_data['x-amz-date'] ?>" />

	<input type="hidden" name="Policy" value='<?= $upload_data['policy'] ?>' />
	<input type="hidden" name="X-Amz-Signature" value="<?= $upload_data['x-amz-signature'] ?>" />
    File: 
    <input type="file"   name="file" /> <br />
    <!-- The elements after this will be ignored -->
    <input type="submit" name="submit" value="Upload to Amazon S3" />
  </form>
</html>

When setting up your front-end, you will like to enable better interface with AJAX upload such that your user’s can have a seamless experience. For this it is recommended to use one of the available libraries(angularjs, jquery or standalone, etc.) . Note that all these can be modified to be used in this set up. You can also see a sample implementation of the angular’s ng-file-upload library in your vdocipher dashboard itself.

The post Redirected: PHP sample video upload from browser to VdoCipher appeared first on VdoCipher Blog.

]]>
https://www.vdocipher.com/blog/2016/03/php-sample-video-upload-from-browser-to-vdocipher/feed/ 0
PHP implementation of VdoCipher API for Video Security https://www.vdocipher.com/blog/2014/12/php-implementation-vdocipher-api/ https://www.vdocipher.com/blog/2014/12/php-implementation-vdocipher-api/#respond Thu, 01 Sep 2022 01:05:38 +0000 http://www.vdocipher.com/blog/?p=224 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 […]

The post PHP implementation of VdoCipher API for Video Security appeared first on VdoCipher Blog.

]]>
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.

The post PHP implementation of VdoCipher API for Video Security appeared first on VdoCipher Blog.

]]>
https://www.vdocipher.com/blog/2014/12/php-implementation-vdocipher-api/feed/ 0