Created
December 29, 2014 16:53
-
-
Save vibhavsinha/c89b597a8dd05f2ce6ff to your computer and use it in GitHub Desktop.
VdoCipher search and display video based on the name of file uploaded or the title of the video
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){ | |
$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"; | |
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; | |
} | |
$params = array( | |
'search'=>array( | |
'title'=>'TITLE_OF_VIDEO' | |
), | |
'page'=>1, | |
'limit'=>30, | |
'type'=>'json' | |
); | |
$video = send("videos", $params); | |
$video = json_decode($video); | |
if(count($video) == 0){ | |
echo "Video not found."; | |
} | |
$video = $video[0]->id; | |
$params = array( | |
'video'=>$video | |
); | |
$OTP = send("otp", $params); | |
$OTP = json_decode($OTP)->otp; | |
?> | |
<span id="vdo<?php echo $OTP; ?>"></span> | |
<script src='https://de122v0opjemw.cloudfront.net/utils/playerInit.php?otp=<?php echo $OTP;?>&height=320&width=480&'></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revision: Compatible to PHP 5.2