PHP Archives - VdoCipher Blog https://www.vdocipher.com/blog/category/php/ Secure Video Streaming Thu, 21 Mar 2024 06:29:23 +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 Archives - VdoCipher Blog https://www.vdocipher.com/blog/category/php/ 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
How to Build an E-Learning Website: 5 Point evaluation https://www.vdocipher.com/blog/2017/01/how-to-build-an-e-learning-website-5-point-evaluation/ https://www.vdocipher.com/blog/2017/01/how-to-build-an-e-learning-website-5-point-evaluation/#respond Tue, 24 Jan 2017 06:59:39 +0000 https://www.vdocipher.com/blog/?p=1609 In this blogpost I discuss how you can build an E-learning website. I make the recommendations on the basis of the following five parameters: Technical Skills required to create the website Features and Customization available Cost of solution for building website Time to build solution Expected Number of students and scaling with increasing numbers The […]

The post How to Build an E-Learning Website: 5 Point evaluation appeared first on VdoCipher Blog.

]]>

Create your e-learning website, and use VdoCipher for secure video hosting

In this blogpost I discuss how you can build an E-learning website. I make the recommendations on the basis of the following five parameters:

  1. Technical Skills required to create the website
  2. Features and Customization available
  3. Cost of solution for building website
  4. Time to build solution
  5. Expected Number of students and scaling with increasing numbers

The four methods that you can use to create your E-learning website are:

  1. Coding using PHP/ ASP/Jave/ Node.JS
  2. Content Management Systems – WordPress, Joomla, Drupal, Moodle
  3. Website Builders – Weebly, Wix, SquareSpace
  4. E-Learning Website builders – Teachable, WebAnywhere

Create e-website website, and secure videos using VdoCipher

Here is a video explaining in full detail all the options. A text version of video is also included below.

Coding Using PHP/ ASP/ Node.JS

Technical Skills required

A website may be built from scratch using PHP, ASP and Node.Js. Naturally building these websites would either require an in-house website developer or should be outsourced to web designer. Which of the coding platforms – PHP, ASP or Node.JS you opt for would depend largely on the preferences and comfort levels of the developer in your team/ the web designer that you hire. PHP is one of the most popular scripting languages, while Node.JS is the newest website runtime environment which has seen massive adoption for websites. Alongside choosing the language, you would need to setup the server and database as well. For building a large website you can use a custom solution with a dedicated server on Amazon Web Services. For single-website usages (the more likely scenario) for E-learning websites, you can opt for shared web server hosting, using for example GoDaddy.

Features and Customization

Since your website is being built from the ground up, you have the widest possible options for customization for features that you wish to incorporate. For instance, as a security mechanism against sharing of login credentials, you may set an upper limit on overall time a student may be logged in to the system. Such a solution can be implemented while building the website code.

One thing that you should make clear is to ensure that the code is well documented. Good documentation ensures continuity between different developer teams.

Cost of Solution

Such a solution would require a dedicated software development team to build. Support and maintenance are also additional issues that you would need to work on.

Time to Build Solution

Keep a time period of 2-3 months for such a website to build. To minimize site development time you should have developed a good understanding of the design and structure of your website, and communicated that to the developer. This would ensure minimal confusion in the website development process

Scale of website and Expected Number

1,000+ expected annual users – You would be able to incorporate features specifically on the basis of user requirements. It is important to make sure that appropriate security features are installed in the website framework.

Content Management Systems – WordPress, Joomla, Drupal, Moodle

Technical Skills required

Such an option mainly requires familiarity with the CMS interface. These skills can be learnt quite easily by beginners. A number of our clients – independent artists and individual teachers – have easily setup their WordPress and Moodle websites for hosting their E-learning courses. There would be a one-time effort in setting up the server though. Moodle video player must be customizable and should be available as a plugin.

Features and Customization

Moodle is an LMS, and is therefore designed as an E-learning platform. WordPress on the other hand is a Content Management System, to which you can add LMS functionality through WordPress plugins.

Cost of Solution

Costs of building websites on Content Management Systems include cost of plugins for adding functionalities. WordPress and Joomla offer plugins such as Sensei, Guru and eMember, which simplify the process of course-creation considerably. Many of the useful plugins available are paid, while a lot of them are free as well (generally free plugins offer specific solutions, while paid plugins bundle a whole lot of useful features together). Cost-wise this is the cheapest solution, as the CMS itself is free – the only costs are the plugins and the server hosting.

Sensei plugin for eLearning - use VdoCipher for secure video hosting

Time to Build Solution

Expect a time to launch between 15 to 30 days for a fully functional CMS hosted site.

Scale of website and Expected Number

Such a solution would work pretty good upto a number of 10,000 students. There is no lower limit to the number of students, as costs are low.

Website Builders – Weebly, Wix, SquareSpace

Technical Skills required

In this solution the website hosting company uses a basic website template that they use.

Features and Customization

Such a website would follow a basic template, and there are not many options to customize additional features.

Cost of Solution

The cost of building websites include purchasing the website template and server hosting.

Time to Build Solution

Fast – You need very little time to deploy such a video hosting solution. Server setup and configuration of the website would take time between 7-10 days.

Scale of website and Expected Number

Implementing such a website is best for the case of fast-deployment of your e-learning platform. Because time of launch and costs are priority in this, such a solution would be appropriate for upto 100 users paying for the course. Beyond this number this solution fails to add the customizations you need to cater to the growing list of users.

VdoCipher provides end-to-end solutions for video, right from hosting, encoding, and encryption to the player. On top of it, you get APIs to manage videos, players, and more.

E-Learning Website builders – Teachable, WebAnywhere

Technical Skills required

There is no coding required. Most features can be implemented using drag-and-drop

Features and Customisation

Teachable and WebAnywhere offer ready-to-use E-Learning themes, Student management options, Media and text addition, Membership Access, Server hosting and Database management.

The features that these sites offer are sufficient for most e-learning website creators. These sites however are not very customizable in terms of additional security features or tweaks in User Interface. UI additions such as adding comment sections to pages, and security restrictions such as restricting login time on page, are not available when you opt for this solution.

Cost of Solution

Costs are dependent on the features you integrate, and the number of students enrolled. Because the websites are designed specifically for e-learning such a solution is somewhat more expensive than the case of ready-to-make websites.

Time to Build Solution

7-10 days

Scale of website and Expected Number

Such a website solution would be appropriate for upto 1000 annual users. This is the approximate number of students you can manage without the need to alter your User Interface and backend. Beyond this number you should explore CMS hosting or creating your own website.

Suggestions

When you set about creating an e-learning website I recommend that you check other websites in similar areas. You can use the tool BuiltWith to analyze the tech stack on which any website is made. If you find that 8 out of 10 of your competitors use a particular tech stack, then implementing that stack would be the most reliable way to build an e-learning site.

Streaming E-Learning Videos And Protection From Piracy

The reasons I am specifically writing a different section on video streaming for e-Learning is because:

  1. Video courses are typically the lifeline of any e-Learning portal and second
  2. Video streaming and safeguarding the video content from piracy is a major technical challenge, which the 4 options discussed do not solve inherently themselves. Most of E-Learning sites use some premium video streaming provider to cater to their streaming needs.

Streaming bufferless for HD worldwide and ensuring smooth delivery to regions in Africa and India with slow connections is a major problem. YouTube is quite good in this aspect, but lacks business friendly customization. Vimeo has a B2B offering that is quite popular and is okay in terms of streaming experience. YouTube and Vimeo use standard streaming protocols to deliver video content, and thus a lot of free plugins and downloaders are able to grab and download the videos. For this reason, a more custom video player, providing higher security and flexibility to manage video related features, is needed for premium videos. Here is the link to implement and compare secure technologies used in video hosting for education. Many of the top e-Learning companies either go for a combination of the above solutions or build proprietary systems of their own (for example Udemy and BYJU’s).

Aspect of Comparison Code from Raw: PHP, ASP, NodeJS, JAVA Moodle, WordPress, Joomla, Drupal + LMS themes + Plugins Ready to launch E-learning site – Teachable, Thinkfic etc Ready to Launch Generic Website – Weebly, Wix
Coding Skills Required Every functionality is full coded, require full stack development team One Time server setup required Nil Nil
Features & Customization All customizations are possible, but takes time and cost Most of Elearning functionalities available, Decent customizable. Have to give up on 10-20% of your custom needs Common Elearning functionalities available, except some themes, major customizations not possible. Elearning feature set integration not so varied – suitable for start simple cases
Cost One time considerable cost, recommended for long term control and stability Quite affordable, themes plugins have one time costs Charges monthly basis, not much burden in form of upfront costs Quite affordable , one time costs
Time 2-3 months to go live, each new feature takes time 1 month typically to go live, additional features doable through plugins , not much time taken Go live in a day, not much feature addition can be done, so no time addition Go live in a day, not much feature addition can be done, so no time addition
Scale Effects Good for large user base companies Good if number of students not going more then 10,000 Good till scale of 1000 Good for starting and testing up , upto 500 paid users
Conclusion Choice of technology depends on comfort of your dev team, ideal for large custom required sites Optimizes cost , features and control of all the options- Most popular option I have seen Good for individual teachers. Have to give up on customizations. Affordable Good for experimentation, Better to choose amongst other 3 for full elearning portal

I will be happy to have feedback and questions in the comments section below or on my LinkedIn profile. You can also share your experience with above technologies and any interesting insights.

A version of this blog was first published on E-learningIndustry.com

FAQs Around Building an E-learning Website

What are the key features to include in an e-learning website to ensure effective learning and user engagement?

Key features should include interactive elements like quizzes and simulations, diverse multimedia content such as videos and infographics to cater to different learning styles, assessment tools for feedback and progress tracking, and social learning features to enable peer interaction and collaboration.

How do content management systems (CMS) like WordPress compare to dedicated e-learning platforms for creating an e-learning site?

CMSs offer flexibility and are cost-effective, while e-learning platforms provide specialized tools but may limit customization.

What are the expected costs and time investment for each method of building an e-learning website?

Costs and timelines vary significantly, from affordable and quick website builders to more time-intensive and costly custom coding.

How does the choice of technology impact the scalability of an e-learning website?

The selection between CMS, custom coding, website builders, and e-learning platforms affects how well the site can scale with increasing numbers of students.

The post How to Build an E-Learning Website: 5 Point evaluation appeared first on VdoCipher Blog.

]]>
https://www.vdocipher.com/blog/2017/01/how-to-build-an-e-learning-website-5-point-evaluation/feed/ 0
Video upload from website or server to VdoCipher API https://www.vdocipher.com/blog/2016/02/video-upload-using-api/ https://www.vdocipher.com/blog/2016/02/video-upload-using-api/#comments Tue, 02 Feb 2016 13:34:04 +0000 https://www.vdocipher.com/blog/?p=392 [Update 24/05/2018] This blog has been updated for API Version v3. A previous version of this blog used API v2. If you are using API v2 you can contact us at support@vdocipher.com. You can use VdoCipher API v3 to build a workflow around your video website as suggested in this blog. The complete API v3 […]

The post Video upload from website or server to VdoCipher API appeared first on VdoCipher Blog.

]]>
[Update 24/05/2018] This blog has been updated for API Version v3. A previous version of this blog used API v2. If you are using API v2 you can contact us at support@vdocipher.com. You can use VdoCipher API v3 to build a workflow around your video website as suggested in this blog. The complete API v3 reference, with sample codes for different backend languages, can be accessed from the API Sample Docs.

We use Amazon AWS storage to store original user videos securely in AWS S3. With an intent to automate their online business, many of our customers wish to allow their users to upload videos directly from their website. To enable this, we have an API call that returns an authenticated policy document which is used video upload into a S3 bucket allotted to your account.

Step 1 (Obtain authorized access):

Create authorized video upload request with your API secret key.

Request
Endpoint: https://dev.vdocipher.com/api/videos?title=videotitile
Method: PUT
HEADER: Authorization: Apisecret a1b2c3e4e5d6
Response
Content-Type: application/json
"clientPayLoad":{
 "policy":
 "key":
 "x-amz-signature": ,
 "x-amz-algorithm": ,
 "x-amz-date": ,
 "x-amz-credential": ,
 "policy":  ,
 "upload_link_secure": ,
}
"video_id":

The API call has returned a set of parameters that must go with the video upload call to the AWS S3 endpoint. We shall refer to this JSON object returned above as uploadData.

The policy document is valid only for the next 1 hour. It is recommended to make the video upload immediately after creating the authorized access. There is also a soft restriction on the number of upload calls every hour, so it is advised to create it only after the user has chosen to upload the video. It should not be made every time somebody loads their dashboard or mobile app.

This call must be made from a secure environment such as your server. This should not be called from a mobile device or the browser to protect your API key. The uploadData should then be passed to user’s device (mobile or browser) to do the file upload.

Step 2 (Video upload via S3 API):

Upload the file to amazon s3 directly. This upload can be made using server code or using an HTML5 form. You can use any third party upload library to make the upload script. The famous ones already have tutorials on setting it up with S3 upload.

application Request
Endpoint: https://{bucket}.s3.amazonaws.com/
Method: POST
Form-Data:
 'x-amz-credential': uploadData['x-amz-credential'],
 'x-amz-algorithm': uploadData['x-amz-algorithm'],
 'x-amz-date' : uploadData['x-amz-date'],
 'x-amz-signature': uploadData['x-amz-signature'],
 'key' : uploadData['key'],
 'policy' : uploadData['policy'],
 'success_action_status' : 201,
 'success_action_redirect' : 'http://example.com'
 'file': <file content>
  • upload_link_secure string – The vdocipher storage location on S3 that has been allocated for this file
  • x-amz-credential string – These must be accompanied in the upload request.
  • x-amz-algorithm string
  • x-amz-date string
  • x-amz-signature string – A signature value that authorizes the form and proves that only vdocipher could have created it.
  • key string – A name for the S3 object that will store the uploaded file’s data
  • policy string – authorization string
  • success_action_status integer – The status code returned upon successful upload if success_action_redirect is not specified.
  • success_action_redirect string – Specifies if to redirect to a URL after a successful post instead of issuing a 201. Set this to an empty string if you do not want to redirect to a specific page.

If everything goes right, the response from the above request should be:

Response
<?xml version="1.0" encoding="UTF-8"?>
<PostResponse>
  <Location>https://{{bucket}}.s3.amazonaws.com/orig%2F5555555555555</Location>
  <Bucket>vdo-ap-southeast</Bucket><Key>orig/5555555555555</Key>
  <ETag>xxxxxxxxxxxxxxxxxx</ETag>
</PostResponse>

You can ignore the content of this response. Now, the video status should be shown as Queued or Processing in the API or on your dashboard. The video will get processed after some time. You can poll the API or configure the web hooks(coming soon) to know the time when video is ready. You should only load the video player if the video is ready.

 

Some sample code for the above operations:

The complete VdoCipher API reference for Server APIs, player embedding and player customizations can be accessed through the API page. You can use VdoCipher API v3 to build a workflow around your video website as suggested in this blog.

The post Video upload from website or server to VdoCipher API appeared first on VdoCipher Blog.

]]>
https://www.vdocipher.com/blog/2016/02/video-upload-using-api/feed/ 2