Last active
October 13, 2020 23:01
-
-
Save vibhavsinha/5a31985447e7541b7f21 to your computer and use it in GitHub Desktop.
VdoCipher upload API example in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include("vdocipher_api.php"); | |
vdo_uploadForm(); | |
/// To use the tags, pass as an argument. Note that this is optioinal | |
/* | |
vdo_uploadForm(array( | |
'tags'=>array('tag1', 'tag2'), | |
)); | |
*/ | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 .= "&". $posts; | |
echo $postData; | |
} | |
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; | |
} | |
function vdo_play($id){ | |
$OTP = send("otp", array( | |
'video'=>$id | |
)); | |
$OTP = json_decode($OTP)->otp; | |
echo "<span id='vdo$OTP'></span>"; | |
echo "<script src='https://de122v0opjemw.cloudfront.net/utils/playerInit.php?otp=$OTP&height=320&width=480&'></script>"; | |
} | |
function vdo_uploadForm($tags = array()){ | |
$OTP = send("formOtp", $tags); | |
$OTP = json_decode($OTP)->formOtp; | |
echo "<span id='vdo$OTP'></span>"; | |
echo "<script src='https://de122v0opjemw.cloudfront.net/utils/formInit.php?o=$OTP'></script>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment