Exemplo n.º 1
0
 public function upload()
 {
     $viddler = new Viddler_V2($this->api_key);
     if (isset($this->userName) && isset($this->password)) {
         $user = $viddler->viddler_users_auth(array('user' => $this->userName, 'password' => $this->password));
         $params = array('sessionid' => $user['auth']['sessionid'], 'title' => $this->getWebTitle(), 'tags' => $this->getWebKeywords(), 'description' => $this->getWebDescription(), 'file' => '@' . $this->video->path);
         $prepare = $viddler->viddler_videos_prepareUpload(array('sessionid' => $user['auth']['sessionid']));
         $response = $viddler->viddler_videos_upload($params, $prepare['upload']['endpoint']);
         //print_r ( $response );
         if (is_array($response)) {
             $videoArray = $response['video'];
             if (is_array($videoArray)) {
                 $this->uploadLocation = $videoArray['url'];
             }
         }
     } else {
         $response = "No username or password to use for uploading";
     }
     return $response;
 }
Exemplo n.º 2
0
<?php

include '../phpviddler2.php';
$v = new Viddler_V2('01171d24e48b43444556524f45b3');
// Get an API key by going to You > Profile & API on Viddler.
?>
<!DOCTYPE html>
<html>
	<head>
		<title>PHPViddler API v2 GET Examples</title>
		
	</head>
	
	<body>
		<h1>PHPViddler GET Examples</h1>
		<p>A few simple examples of retrieving some videos from Viddler's API using PHPViddler.</p>
		
		
		<h2><a href="http://developers.viddler.com/documentation/api-v2/">viddler.videos.getByUser</a></h2>
		<p>Some videos based on a user - viddlerdevtest (a Viddler account we use for testing)</p>
		<p><?php 
// Get videos (page 1, videos 5)
$videos = $v->viddler_videos_getByUser(array('user' => 'viddlerdevtest', 'per_page' => 5, 'page' => 1));
/* Debug only 
		echo '<pre>';
		print_r($videos);
		echo '</pre>';
		*/
// Loop through videos showing just the thumbnail
// with a link to the video itself.
foreach ($videos['list_result']['video_list'] as $video) {
<?php

//Set no time limit (in case of big uploads)
set_time_limit(0);
//Include your viddler API wrapper
include '../phpviddler.php';
/**
1. Create viddler object
2. Authenticate as you
3. Set session id
**/
$v = new Viddler_V2('YOUR API KEY');
$auth = $v->viddler_users_auth(array('user' => 'YOUR USERNAME', 'password' => 'YOUR PASSWORD'));
$session_id = isset($auth['auth']['sessionid']) ? $auth['auth']['sessionid'] : NULL;
/**
If session id is empty, something went wrong.
You probably want to handle the error better,
but this is for example purposes only.
**/
if (empty($session_id)) {
    print '<pre>';
    print_r($auth);
    print '</pre>';
    exit;
}
/**
1. Call prepareUpload
2. Get endpoint
3. Get token
**/
$response = $v->viddler_videos_prepareUpload(array('sessionid' => $session_id));
Exemplo n.º 4
0
<?php

//Example to auth as you and get your videos
include '../phpviddler.php';
//Create viddler object using HTTPS:443
$v = new Viddler_V2('YOUR API KEY', TRUE);
//Authenticate as you
//Always a good idea even if your profile is public
//Because if at anytime you turn to a private account
//Your application will still work ;)
$auth = $v->viddler_users_auth(array('user' => 'YOUR USERNAME', 'password' => 'YOUR PASSWORD'));
//Get your session id
$session_id = isset($auth['auth']['sessionid']) ? $auth['auth']['sessionid'] : '';
//If no session id, print errors
if (!empty($session_id)) {
    $info = $v->viddler_users_getProfile(array('sessionid' => $session_id));
    //If any errors print them out
    //This should NOT be done in a production application
    //An exception should be used instead
    //For example purposes only
    if (isset($info['error'])) {
        echo '<pre>';
        print_r($info);
        echo '</pre>';
        exit;
    }
} else {
    echo '<pre>';
    print_r($auth);
    echo '</pre>';
    exit;
Exemplo n.º 5
0
         if ($id != "") {
             $sqlUpdate = "update fn_user_finao set updateddate=NOW(),updatedby=" . $user_id . " where user_finao_id=" . $id;
             mysql_query($sqlUpdate);
         }
     }
 } elseif ($_REQUEST['json'] == 'getimageorvideo') {
     $json = array();
     $type = $_REQUEST['type'];
     //Image/Video
     $srctype = $_REQUEST['srctype'];
     //tile/finao/journal
     $srcid = $_REQUEST['srcid'];
     $user_id = $_REQUEST['user_id'];
     set_time_limit(0);
     include 'phpviddler.php';
     $v = new Viddler_V2('1mn4s66e3c44f11rx1xd');
     $auth = $v->viddler_users_auth(array('user' => 'nageshvenkata', 'password' => 'V1d30Pl@y3r'));
     $session_id = isset($auth['auth']['sessionid']) ? $auth['auth']['sessionid'] : NULL;
     $sqlSelect = "select * from fn_lookups where lookup_type='uploadtype' and Lower(lookup_name)='" . strtolower($type) . "'";
     $sqlSelectRes = mysql_query($sqlSelect);
     if (mysql_num_rows($sqlSelectRes) > 0) {
         while ($sqlSelectDet = mysql_fetch_assoc($sqlSelectRes)) {
             $lookup_id = $sqlSelectDet['lookup_id'];
         }
     }
     $sqlSelectSrctype = "select * from fn_lookups where lookup_type='uploadsourcetype' and Lower(lookup_name)='" . strtolower($srctype) . "'";
     $sqlSelectSrctypeRes = mysql_query($sqlSelectSrctype);
     if (mysql_num_rows($sqlSelectSrctypeRes) > 0) {
         while ($sqlSelectSrctypeDet = mysql_fetch_assoc($sqlSelectSrctypeRes)) {
             $srclookup_id = $sqlSelectSrctypeDet['lookup_id'];
         }
Exemplo n.º 6
0
 public function actionCheckVideoStatus()
 {
     //print_r($_POST);
     /*SELECT * FROM `fn_uploaddetails` WHERE `upload_sourceid` = 1748 and `uploadedby` = 20 and `videoid` !='' and status = 1 and videostatus != 'ready'*/
     $ids = array();
     $Criteria = new CDbCriteria();
     $Criteria->condition = "`upload_sourceid` = " . $_POST['finaoid'] . " and `uploadedby` = " . $_POST['userid'] . " and `videoid` !='' and status = 1 and videostatus != 'ready'";
     $uploadids = Uploaddetails::model()->findAll($Criteria);
     foreach ($uploadids as $finaoids) {
         $ids[] = $finaoids->uploaddetail_id . '-' . $finaoids->upload_sourceid;
     }
     foreach ($ids as $updet) {
         //echo $updet;
         $datastring = $updet;
         $item = explode(" ", $datastring);
         $item[0];
         // uploadid
         $item[1];
         // uploadsourceid or finaoid
         $updetupload = new Uploaddetails();
         $updetupload = Uploaddetails::model()->findByAttributes(array('uploaddetail_id' => $item[0]));
         if (!empty($updetupload)) {
             if ($updetupload->videostatus != 'ready') {
                 //echo $updetupload->videostatus;
                 $vidler = Yii::app()->getComponents(false);
                 $user = $vidler['vidler']['user'];
                 $pass = $vidler['vidler']['pwd'];
                 $api_key = $vidler['vidler']['appkey'];
                 $v = new Viddler_V2($api_key);
                 $auth = $v->viddler_users_auth(array('user' => $user, 'password' => $pass));
                 $sessionid = $auth['auth']['sessionid'];
                 $results = $v->viddler_videos_getDetails(array('sessionid' => $sessionid, 'video_id' => $updetupload->videoid));
                 $i = 0;
                 if ($results['video']['status'] == 'ready') {
                     //echo 'video'.$results['video']['status'];
                     $i++;
                     $updetupload->videostatus = $results['video']['status'];
                     if ($updetupload->save(false)) {
                         echo 1;
                         //succes
                     } else {
                         echo 0;
                         //fail
                     }
                 }
                 //echo $i.'updated';
             }
         }
     }
 }
Exemplo n.º 7
0
<?php

//Example to auth as you and get your videos
include '../phpviddler.php';
//Create viddler object using HTTP:80
$v = new Viddler_V2('YOUR API KEY');
// Search videos: type=allvideos, query=iphone, videos 5
$videos = $v->viddler_videos_search(array('type' => 'allvideos', 'query' => 'iphone', 'per_page' => 5));
//If any errors print them out
//This should NOT be done in a production application
//An exception should be used instead
//For example purposes only
if (isset($videos['error'])) {
    echo '<pre>';
    print_r($videos);
    echo '</pre>';
    exit;
}
//Set videos
$videos = isset($videos['list_result']['video_list']) ? $videos['list_result']['video_list'] : array();
?>
<!DOCTYPE html>
<html>
	<head>
		<title>Search All Videos</title>
	</head>
	<body>
		<h1>Search All Videos</h1>
		<p>A few simple examples of retrieving some videos from Viddler's API using PHPViddler.</p>
		<h2><a href="http://developers.viddler.com/documentation/api-v2/">viddler.videos.search</a></h2>
		<p>Search all of Viddler's public videos for "iPhone".</p>
Exemplo n.º 8
0
<?php

require_once './config.php';
require_once '../../src/lib/phpviddler/phpviddler.php';
$v = new Viddler_V2(VIDDLER_API_KEY);
$auth = $v->viddler_users_auth(array('user' => VIDDLER_USERNAME, 'password' => VIDDLER_PASSWORD));
if ($_GET['action'] == 'prepareUpload') {
    $params = array('sessionid' => $auth['auth']['sessionid']);
    if (VIDDLER_ALLOW_VIDEO_REPLACE) {
        $params['allow_replace'] = true;
    }
    $response = $v->viddler_videos_prepareUpload($params);
    header('Content-Type: application/json');
    //Bacause PHP library uses php responses
    $response['upload']['endpoint'] = str_replace('.php', '.json', $response['upload']['endpoint']);
    echo json_encode($response);
}
Exemplo n.º 9
0
 public function actionGetadminVideodetail()
 {
     //print_r($_REQUEST);exit;
     // echo 'HEllo ';
     $userid = Yii::app()->session['login']['id'];
     $groupid = $_REQUEST['groupid'];
     $videoid = "";
     $results = "";
     $videoembcode = "";
     $srctype = "";
     $video = Uploaddetails::model()->findByAttributes(array('upload_sourcetype' => 64, 'upload_sourceid' => $groupid));
     if ($video) {
         // echo 'updating';exit;
         //print_r($_POST);exit;
         $video->video_embedurl = '';
         $video->upload_sourcetype = 64;
         //Admin Video
         if (isset($_REQUEST["videoid"])) {
             $videoid = $_REQUEST["videoid"];
             $vidler = Yii::app()->getComponents(false);
             $user = $vidler['vidler']['user'];
             $pass = $vidler['vidler']['pwd'];
             $api_key = $vidler['vidler']['appkey'];
             $callback_url = '/';
             $v = new Viddler_V2($api_key);
             $auth = $v->viddler_users_auth(array('user' => $user, 'password' => $pass));
             $sessionid = $auth['auth']['sessionid'];
             $results = $v->viddler_videos_getDetails(array('sessionid' => $sessionid, 'video_id' => $videoid));
             //print_r($results);
             $description = $results['video']['description'];
             if (trim($description) == '') {
                 $video->uploadtype = 35;
             } else {
                 $video->uploadtype = 62;
                 $video->upload_text = $results['video']['description'];
             }
         } else {
             $videoid = '';
             $videoembcodeURL = $_REQUEST['emburl'];
             $videodesc = $_REQUEST['embdescr'];
             $srctype = $_REQUEST['sourcetype'];
             $yt_vid = $this->extractUTubeVidId($videoembcodeURL);
             $videoembcode = $this->generateYoutubeEmbedCode($yt_vid, 230, 230);
             $videoembImgUrl = "http://img.youtube.com/vi/" . $yt_vid . "/mqdefault.jpg";
             if (!empty($_REQUEST['journaltxt'])) {
                 $video->uploadtype = 62;
                 $video->upload_text = $_REQUEST['journaltxt'];
             } else {
                 $video->uploadtype = 35;
             }
         }
         $video->videoid = $videoid;
         $video->videostatus = "ready";
         $video->video_img = isset($results['video']['thumbnail_url']) ? $results['video']['thumbnail_url'] : $videoembImgUrl;
         $video->video_caption = isset($results['video']['title']) ? $results['video']['title'] : $videodesc;
         $video->video_embedurl = $videoembcode;
         if ($video->save(false)) {
             if (isset($_REQUEST["videoid"])) {
                 if (isset($_REQUEST["groupid"]) && !empty($_REQUEST["groupid"])) {
                     $this->redirect(Yii::app()->createUrl('group/dashboard', array('groupid' => $_REQUEST['groupid'])));
                 }
             } else {
                 echo $_REQUEST['groupid'];
             }
         }
     } else {
         //echo 'New';exit;
         $model = new Uploaddetails();
         //Type should be here...
         $model->upload_sourcetype = 64;
         //Admin Video
         if (isset($_REQUEST["videoid"])) {
             $videoid = $_REQUEST["videoid"];
             $vidler = Yii::app()->getComponents(false);
             $user = $vidler['vidler']['user'];
             $pass = $vidler['vidler']['pwd'];
             $api_key = $vidler['vidler']['appkey'];
             $callback_url = '/';
             $v = new Viddler_V2($api_key);
             $auth = $v->viddler_users_auth(array('user' => $user, 'password' => $pass));
             $sessionid = $auth['auth']['sessionid'];
             $results = $v->viddler_videos_getDetails(array('sessionid' => $sessionid, 'video_id' => $videoid));
             print_r($results);
             $description = $results['video']['description'];
             if (trim($description) == '') {
                 $model->uploadtype = 35;
             } else {
                 $model->uploadtype = 62;
                 $model->upload_text = $results['video']['description'];
             }
         } else {
             $videoembcodeURL = $_REQUEST['emburl'];
             $videodesc = $_REQUEST['embdescr'];
             $srctype = $_REQUEST['sourcetype'];
             $yt_vid = $this->extractUTubeVidId($videoembcodeURL);
             $videoembcode = $this->generateYoutubeEmbedCode($yt_vid, 230, 230);
             $videoembImgUrl = "http://img.youtube.com/vi/" . $yt_vid . "/mqdefault.jpg";
             if (!empty($_REQUEST['journaltxt'])) {
                 $model->uploadtype = 62;
                 $model->upload_text = $_REQUEST['journaltxt'];
             } else {
                 $model->uploadtype = 35;
             }
         }
         //Group id should be here...
         $model->upload_sourceid = $groupid;
         $model->uploadedby = $userid;
         $model->uploadeddate = new CDbExpression('NOW()');
         $model->status = 1;
         $userid = Yii::app()->session['login']['id'];
         $model->updatedby = $userid;
         $model->updateddate = new CDbExpression('NOW()');
         $model->videoid = $videoid;
         $model->videostatus = "ready";
         $model->video_img = isset($results['video']['thumbnail_url']) ? $results['video']['thumbnail_url'] : $videoembImgUrl;
         $model->video_caption = isset($results['video']['title']) ? $results['video']['title'] : $videodesc;
         $model->video_embedurl = $videoembcode;
         if ($model->save(false)) {
             if (isset($_REQUEST["videoid"])) {
                 if (isset($_REQUEST["groupid"]) && !empty($_REQUEST["groupid"])) {
                     $this->redirect(Yii::app()->createUrl('group/dashboard', array('groupid' => $_REQUEST['groupid'])));
                 }
             } else {
                 echo $_REQUEST['groupid'];
             }
         }
     }
 }
Exemplo n.º 10
0
<?php

//Example to auth as you and get your videos
include '../phpviddler.php';
//Create viddler object using HTTPS:443
$v = new Viddler_V2('YOUR API KEY', TRUE);
//Authenticate as you
//Always a good idea even if your profile/videos are public
//Because if at anytime you turn to a private account
//Your application will still work ;)
$auth = $v->viddler_users_auth(array('user' => 'YOUR USERNAME', 'password' => 'YOUR PASSWORD'));
//Get your session id
$session_id = isset($auth['auth']['sessionid']) ? $auth['auth']['sessionid'] : '';
//If no session id, print errors
if (!empty($session_id)) {
    $videos = $v->viddler_videos_getByUser(array('sessionid' => $session_id, 'per_page' => 5, 'page' => 1));
    //If any errors print them out
    //This should NOT be done in a production application
    //An exception should be used instead
    //For example purposes only
    if (isset($videos['error'])) {
        echo '<pre>';
        print_r($videos);
        echo '</pre>';
        exit;
    }
    $videos = isset($videos['list_result']['video_list']) ? $videos['list_result']['video_list'] : array();
} else {
    echo '<pre>';
    print_r($auth);
    echo '</pre>';
Exemplo n.º 11
0
<?php

// You can run this on your server or via command line.
include '../phpviddler.php';
$api_key = '';
$user = '';
$password = '';
$file = '';
$viddler = new Viddler_V2($api_key);
$user = $viddler->viddler_users_auth(array('user' => $user, 'password' => $password));
$params = array('sessionid' => $user['auth']['sessionid'], 'title' => 'test20101215', 'tags' => 'tag1,tag2,tag3', 'description' => 'desc here', 'file' => '@' . $file);
$prepare = $viddler->viddler_videos_prepareUpload(array('sessionid' => $user['auth']['sessionid']));
$results = $viddler->viddler_videos_upload($params, $prepare['upload']['endpoint']);
print_r($results);
echo "\n";
Exemplo n.º 12
0
function uploaddata($type, $sourcetype, $finaoid, $userid, $uploadtext, $data, $captiondata)
{
    $target_path = $globalpath . "images/uploads/finaoimages/";
    $target_thumb = $globalpath . "images/uploads/finaoimages/thumb/";
    $target_medium = $globalpath . "images/uploads/finaoimages/medium/";
    $upload_path = "/images/uploads/finaoimages";
    $query = "insert into fn_uploaddetails (`uploadtype`,`upload_text`,`upload_sourcetype`, `upload_sourceid`, `uploadedby`, `uploadeddate`, `status`) values ('{$type}','{$uploadtext}','{$sourcetype}','{$finaoid}','{$userid}',now(),1)";
    mysql_query($query);
    $uploadid = mysql_insert_id();
    if (!empty($data)) {
        if ($data['image1']['name'] != '') {
            $sno = 0;
            foreach ($data as $key => $val) {
                $name = $val['name'];
                $uploadfile_name = $finaoid . "-" . $name;
                $tmpname = $val['tmp_name'];
                $target_main = $target_path . $uploadfile_name;
                $target_thumb = $target_thumb . $uploadfile_name;
                $target_medium = $target_medium . $uploadfile_name;
                @move_uploaded_file($tmpname, $target_main);
                $resize = new ResizeImage($target_main);
                $resize->resizeTo(100, 100, 'default');
                $resize->saveImage($target_thumb);
                $resize_m = new ResizeImage($target_main);
                $resize_m->resizeTo(240, 240, 'default');
                $resize_m->saveImage($target_medium);
                $query = "insert into fn_images (`upload_id`,`uploadfile_name`,`uploadfile_path`, `caption`, `uploadedby`, `uploadeddate`, `status`) values ('{$uploadid}','{$uploadfile_name}','{$upload_path}','{$captiondata[$sno]}','{$userid}',now(),1)";
                mysql_query($query);
                $sno++;
            }
        } else {
            $target_path = $target_path . $finaoid . "-" . basename($data['video']['name']);
            @move_uploaded_file($data['video']['tmp_name'], $target_path);
            set_time_limit(0);
            include 'phpviddler.php';
            $v = new Viddler_V2('145i86zgnzi1h1xln0ly');
            $auth = $v->viddler_users_auth(array('user' => ' finaonation', 'password' => 'Finao123'));
            $session_id = isset($auth['auth']['sessionid']) ? $auth['auth']['sessionid'] : NULL;
            $response = $v->viddler_videos_prepareUpload(array('sessionid' => $session_id));
            $endpoint = isset($response['upload']['endpoint']) ? $response['upload']['endpoint'] : NULL;
            $token = isset($response['upload']['token']) ? $response['upload']['token'] : NULL;
            $query = array('uploadtoken' => $token, 'title' => 'Video from iphone App', 'description' => 'Video from iphone App', 'tags' => 'testing,upload', 'file' => '@../../preprod/images/uploads/finaoimages/' . $finaoid . "-" . basename($data['video']['name']));
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $endpoint);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
            curl_setopt($ch, CURLOPT_HEADER, TRUE);
            curl_setopt($ch, CURLOPT_NOBODY, FALSE);
            curl_setopt($ch, CURLOPT_TIMEOUT, 0);
            curl_setopt($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
            $response = curl_exec($ch);
            $info = curl_getinfo($ch);
            $header_size = $info['header_size'];
            $header = substr($response, 0, $header_size);
            $video = unserialize(substr($response, $header_size));
            curl_close($ch);
            @unlink('../../preprod/images/uploads/finaoimages/' . $finaoid . "-" . basename($data['video']['name']));
            $videoid = $video['video']['id'];
            $results = $v->viddler_videos_getDetails(array('sessionid' => $session_id, 'video_id' => $videoid));
            $videostatus = $results['video']['status'];
            $video_img = $results['video']['thumbnail_url'];
            $query = "insert into fn_videos (`upload_id`,`videoid`,`videostatus`, `video_img`, `caption`, `uploadedby`, `uploadeddate`, `status`) values ('{$uploadid}','{$videoid}','{$videostatus}','{$video_img}','{$captiondata['0']}','{$userid}',now(),1)";
            mysql_query($query);
        }
    }
    // updating the current date time in fn_user_finao
    $sqlUpdate = "update fn_user_finao set updateddate=NOW(),updatedby=" . $userid . " where user_finao_id=" . $finaoid;
    mysql_query($sqlUpdate);
    // end of fn_user_finao update
}