Last active
March 5, 2016 06:07
-
-
Save vibhavsinha/520b9c951cd6b8cbaee5 to your computer and use it in GitHub Desktop.
VdoCipher API implementation in PHP with adding watermark
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_FAILONERROR, true); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true); | |
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($curl, CURLOPT_VERBOSE, true); | |
curl_setopt($curl, CURLOPT_FAILONERROR, false); | |
$getData = http_build_query($params); | |
$postData = "clientSecretKey=CLIENT_SECRET_KEY"; | |
if ($posts) { | |
$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); | |
if (!$html) { | |
print_r(curl_error($curl)); | |
die(); | |
} | |
curl_close($curl); | |
return $html; | |
} | |
$params = array( | |
'video' => 'VIDEO_ID' | |
); | |
$annoData = "[". | |
"{'type':'image', 'url':'https://example.com/url/to/image.jpg', 'alpha':'0.8', 'x':'100','y':'200'},". | |
"{'type':'rtext', 'text':'moving text', 'alpha':'0.8', 'color':'0xFF0000', 'size':'12','interval':'5000'},". | |
"{'type':'text', 'text':'static text', 'alpha':'0.5' , 'x':'10', 'y':'100', 'co lor':'0xFF0000', 'size':'12'}". | |
"]"; | |
$anno = urlencode($annoData); | |
$OTP = send("otp", $params, "annotate=". $anno); | |
$OTP = json_decode($OTP)->otp; | |
echo <<<EOF | |
<div id="vdo$OTP" style="height:400px;width:640px;max-width:100%;"></div> | |
<script> | |
(function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){ (v[o].d=v[o].d||[]).push(a);}; | |
if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0]; | |
a.async=1; a.src=e; m.parentNode.insertBefore(a,m);} | |
})(window,document,'script','//de122v0opjemw.cloudfront.net/vdo.js','vdo'); | |
vdo.add({ | |
o: "$OTP", | |
}); | |
</script>"; | |
EOF; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment