Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     //When the site opens, get a list of all Vimeo videos and add new ones to the database
     $client_id = "9ce900dd2edc201d9200016ba346a99f23b66c90";
     $client_secret = "Qp7BA1pI2ya5+5WhTe6lQIU8svh5JT2k84KaX1cC78wXkB0gpJHnJr6qILeWRZu6ZFI7sWgMvUV8XjsO8oL7IPGEKiGysKo7PxCuNwrnVUllvHR93fhMTjHzrjw8NrG6";
     $token = "d66beec735c5b122715ea56508efe51f";
     $vimeo_id = "user21531832";
     require APPPATH . "/libraries/vendor/vimeo/vimeo-api/autoload.php";
     $vimeo = new \Vimeo\Vimeo($client_id, $client_secret, $token);
     $videos = $vimeo->request('/users/user21531832/videos');
     $videos = $videos['body'];
     //var_dump($videos);
     $video_count = $videos['total'];
     $video_array = $videos['data'];
     //var_dump($video_array);
     $videos = array();
     foreach ($video_array as $video) {
         //var_dump($video);
         //$data['videos'] = $val;
         //var_dump($val['id']);
         $videos[] = $video['uri'];
         $this->video_model->add_videos($videos);
     }
 }
Exemplo n.º 2
0
function get_vimeo_variable()
{
    $vimeo_config = get_vimeo_config();
    $lib = new \Vimeo\Vimeo($vimeo_config['client_id'], $vimeo_config['client_secret']);
    if ($vimeo_config['access_token']) {
        $lib->setToken($vimeo_config['access_token']);
    }
    return $lib;
}
Exemplo n.º 3
0
<?php

require "../vendor/vimeo/vimeo-api/autoload.php";
require "./config.php";
$lib = new \Vimeo\Vimeo($client_id, $client_secret);
$lib->setToken($personal_token);
$file = $argv[1];
if (is_file($file)) {
    //$file = '/var/www/html/vimeo_upload/data/SampleVideo_1080x720_1mb.mp4';
    //echo $file."\n";
    //$response = $lib->upload($file, false);
} else {
    echo "File not found ({$file}).\n";
}
 public function updateVimeoData()
 {
     if ($this->VimeoProcessingStatus == 'finished') {
         $this->VimeoProcessingStatus = 'updating';
         $this->write();
         $this->appendLog($this->getLogFile(), 'IsProcessed - updating');
         $lib = new \Vimeo\Vimeo(Config::inst()->get('VimeoVideoFile', 'client_id'), Config::inst()->get('VimeoVideoFile', 'client_secret'), Config::inst()->get('VimeoVideoFile', 'access_token'));
         // Send a request to vimeo for uploading the new video
         $video_data = $lib->request($this->VimeoURI);
         $this->extractUrls($video_data);
         // Set Title, Album and player preset
         $lib->request($this->VimeoURI, array('name' => $this->Name), 'PATCH');
         if (Config::inst()->get('VimeoVideoFile', 'album_id')) {
             $res = $lib->request('/me/albums/' . Config::inst()->get('VimeoVideoFile', 'album_id') . $this->VimeoURI, array(), 'PUT');
             $this->appendLog($this->getLogFile(), 'Updated Album', print_r($res, true));
         }
         if (Config::inst()->get('VimeoVideoFile', 'preset_id')) {
             $res = $lib->request($this->VimeoURI . '/presets/' . Config::inst()->get('VimeoVideoFile', 'preset_id'), array(), 'PUT');
             $this->appendLog($this->getLogFile(), 'Updated Player Preset', print_r($res, true));
         }
         return true;
     } else {
         return false;
     }
 }
 protected function onBeforeDelete()
 {
     parent::onBeforeDelete();
     $lib = new \Vimeo\Vimeo(Config::inst()->get('VimeoVideoFile', 'client_id'), Config::inst()->get('VimeoVideoFile', 'client_secret'), Config::inst()->get('VimeoVideoFile', 'access_token'));
     $video_data = $lib->request($this->VimeoURI, array(), 'DELETE');
 }
Exemplo n.º 6
0
<?php

session_start();
require_once 'vendor/autoload.php';
define('CLIENT_ID', '');
define('CLIENT_SECRET', '');
define('REDIRECT_URI', 'http://localhost/tester/vimeo-slim/login');
$app = new \Slim\Slim(array('view' => new \Slim\Views\Twig()));
$view = $app->view();
$view->parserOptions = array('debug' => true, 'cache' => dirname(__FILE__) . '/cache');
$vimeo = new \Vimeo\Vimeo(CLIENT_ID, CLIENT_SECRET);
$app->get('/token', function () use($app, $vimeo) {
    $token = $vimeo->clientCredentials();
    echo $token['body']['access_token'];
});
$app->get('/login', function () use($app, $vimeo) {
    if ($app->request->get('code') && $app->request->get('state') == $_SESSION['state']) {
        $code = $app->request->get('code');
        $token = $vimeo->accessToken($code, REDIRECT_URI);
        $access_token = $token['body']['access_token'];
        $vimeo->setToken($access_token);
        $_SESSION['user.access_token'] = $access_token;
        $page_data = array('user' => $token['body']['user']);
    } else {
        $scopes = array('public', 'private', 'interact');
        $state = substr(str_shuffle(md5(time())), 0, 10);
        $_SESSION['state'] = $state;
        $url = $vimeo->buildAuthorizationEndpoint(REDIRECT_URI, $scopes, $state);
        $page_data = array('url' => $url);
    }
    $app->render('login.php', $page_data);
Exemplo n.º 7
0
    $app_secret = '360648f00a1e386b02511a7b985c509285adb343';
    $vimeo = new Vimeo\Vimeo($app_id, $app_secret);
    $redirect_url = 'http://localhost:7778/vimeo/connect';
    $connect_url = $vimeo->buildAuthorizationEndpoint($redirect_url);
    return Redirect::to($connect_url);
});
Route::get('/vimeo/connect', function () {
    return Input::get();
    // vimeo access token:
    // 9f58506a9862177aea600ea3700fdb2519129a40
});
Route::get('/vimeo/advanced', function () {
    $app_id = '1149255775453ab09e7d68c379d5feafa2486191';
    $app_secret = '360648f00a1e386b02511a7b985c509285adb343';
    $access_token = '9f58506a9862177aea600ea3700fdb2519129a40';
    $vimeo = new Vimeo\Vimeo($app_id, $app_secret);
    $vimeo->setToken($access_token);
    $vimeo->request('/me/videos', array('type' => 'POST', 'redirect_url' => $redirect_target), 'POST');
});
Route::get('/get/vimeo', function () {
    $videosearch_params = array('index' => 'video-websites', 'type' => 'video');
    $videosearch_params['body']['query']['filtered']['query']['match']['website_id'] = 4;
    $videosearch_params['body']['query']['filtered']['filter']['bool']['must'][]['term']['user_id'] = 1;
    $videosearch_response = Es::search($videosearch_params);
    return $videosearch_response;
});
Route::get('/vimeo/cache', function () {
    $user_id = 1;
    $video_page = 2;
    $website_id = 4;
    $channel_id = 4;
Exemplo n.º 8
0
 public function action_index()
 {
     require $_SERVER['DOCUMENT_ROOT'] . "/application/vendor/vimeo/autoload.php";
     $client_id = '';
     $client_secret = '';
     $token = '';
     $token_secret = '';
     $vimeo = new \Vimeo\Vimeo($client_id, $client_secret, $token);
     $categories = $vimeo->request("/categories");
     foreach ($categories['body']['data'] as $category) {
         // $categoryArray = array('Animation', 'Arts & Design', 'Cameras & Techniques', 'Comedy', 'Documentary', 'Experimental', 'Fashion', 'Food', 'Instructionals', 'Music', 'Narrative', 'Personal', 'Reporting & Journalism', 'Sports', 'Talks'));
         // if (in_array($category['name'], $categoryArray)) {
         // 	continue;
         // }
         $categoryShortName = str_replace('/categories/', '', $category['uri']);
         for ($i = 1; $i <= 20; $i++) {
             sleep(1);
             echo 'page ' . $i . ' of ' . $category['uri'];
             $videos = $vimeo->request($category['uri'] . '/videos', array('sort' => 'plays', 'per_page' => 50, 'page' => $i));
             // echo '<pre>'; print_r($videos); echo '</pre>'; exit;
             foreach ($videos['body']['data'] as $video) {
                 // Prepares video data array
                 $videoSpecs['uri'] = $video['uri'];
                 $videoSpecs['name'] = $video['name'];
                 $videoSpecs['description'] = $video['description'];
                 $videoSpecs['link'] = $video['link'];
                 $videoSpecs['duration'] = $video['duration'];
                 $videoSpecs['width'] = $video['width'];
                 $videoSpecs['height'] = $video['height'];
                 $videoSpecs['create_time'] = $video['created_time'];
                 $videoSpecs['plays'] = $video['stats']['plays'];
                 $videoSpecs['likes'] = $video['metadata']['connections']['likes']['total'];
                 $videoSpecs['comments'] = $video['metadata']['connections']['comments']['total'];
                 if ($video['privacy']['embed'] === 'public') {
                     $videoSpecs['embeddable'] = true;
                 } else {
                     $videoSpecs['embeddable'] = false;
                 }
                 // Look for existing record
                 $videoOrm = ORM::factory('Video')->where('uri', '=', $video['uri'])->find_all()->as_array();
                 if (sizeOf($videoOrm) === 0) {
                     // Add record to DB if it doesn't exist
                     $videoRecord = new Model_Video();
                     $videoRecord->values($videoSpecs);
                     $videoRecord->save();
                     $videoId = $videoRecord->id;
                     $videoOrm = ORM::factory('Video')->where('uri', '=', $video['uri'])->find();
                     // Populate tags table with video data
                     foreach ($video['tags'] as $tag) {
                         $tagRecord = new Model_Tag();
                         $tagRecord->values(array('video_id' => $videoId, 'name' => $tag['name']));
                         $tagRecord->save();
                     }
                 } else {
                     // Update record if it exists
                     $videoOrm[0]->values($videoSpecs);
                     $videoOrm[0]->save();
                     $videoId = $videoOrm[0]->id;
                 }
                 // Populate categories table category data if that video and category association is not already stored
                 $categoryOrm = ORM::factory('Category')->where('video_id', '=', $videoId)->and_where('short_name', '=', $categoryShortName)->find_all();
                 if ($categoryOrm->count() === 0) {
                     $categoryRecord = new Model_Category();
                     $categoryRecord->values(array('video_id' => $videoId, 'name' => $category['name'], 'short_name' => $categoryShortName));
                     $categoryRecord->save();
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
<?php

session_start();
require_once 'vendor/autoload.php';
define('CLIENT_ID', '');
define('CLIENT_SECRET', '');
define('REDIRECT_URI', 'http://localhost/tester/vimeo-slim/login');
$app = new \Slim\Slim(array('view' => new \Slim\Views\Twig()));
$view = $app->view();
$view->parserOptions = array('debug' => true, 'cache' => dirname(__FILE__) . '/cache');
$vimeo = new \Vimeo\Vimeo(CLIENT_ID, CLIENT_SECRET);
$app->get('/token', function () use($app, $vimeo) {
    $token = $vimeo->clientCredentials();
    echo $token['body']['access_token'];
});
$app->get('/login', function () use($app, $vimeo) {
    if ($app->request->get('code') && $app->request->get('state') == $_SESSION['state']) {
        $code = $app->request->get('code');
        $token = $vimeo->accessToken($code, REDIRECT_URI);
        $access_token = $token['body']['access_token'];
        $vimeo->setToken($access_token);
        $_SESSION['user.access_token'] = $access_token;
        $page_data = array('user' => $token['body']['user']);
    } else {
        $scopes = array('public', 'private');
        $state = substr(str_shuffle(md5(time())), 0, 10);
        $_SESSION['state'] = $state;
        $url = $vimeo->buildAuthorizationEndpoint(REDIRECT_URI, $scopes, $state);
        $page_data = array('url' => $url);
    }
    $app->render('login.php', $page_data);
Exemplo n.º 10
-1
/**
 * v 1.0.2
 * Copyright 2015, Honkytonk Films
 * http://www.klynt.net
 * */
function requestVideoInfo($videoId)
{
    require_once 'lib/vimeo/autoload.php';
    $vimeo = new Vimeo\Vimeo(VIMEO_CLIENT_ID, VIMEO_CLIENT_SECRET, VIMEO_CLIENT_ACCESS_TOKEN);
    $video = $vimeo->request('/videos/' . $videoId);
    if ($video) {
        $body = $video['body'];
        $tags = array();
        foreach ($body['tags'] as $tag) {
            array_push($tags, $tag['tag']);
        }
        $max_thumbnail_size = 0;
        $thumbnail = '';
        foreach ($body['pictures']['sizes'] as $size) {
            if ($size['width'] > $max_thumbnail_size) {
                $max_thumbnail_size = $size['width'];
                $thumbnail = $size['link'];
            }
        }
        $urls = array();
        $qualities = array("sd", "hd", "mobile");
        foreach ($body['files'] as $file) {
            if (in_array($file['quality'], $qualities)) {
                $rate = intval($file['size'] / $body['duration'] * 8);
                $urls[strval($rate)] = $file['link'];
            }
        }
        return array('name' => $body['name'], 'duration' => $body['duration'], 'width' => $body['width'], 'height' => $body['height'], 'description' => $body['description'], 'tags' => join(',', $tags), 'thumbnail' => $thumbnail, 'urls' => $urls);
    } else {
        return null;
    }
}