示例#1
0
 function calcula()
 {
     //mirar si hay video
     $obtenido = array('titulo' => 'Canal de Historia', 'enlaces' => array());
     if (!enString($this->web_descargada, '<iframe')) {
         return;
     }
     preg_match_all('@<iframe src="(.*?)"@', $this->web_descargada, $matches);
     dbug_r($matches);
     foreach ($matches[1] as $url) {
         dbug($url);
         if (strpos($url, '//player.vimeo') === 0) {
             $url = 'http:' . $url;
             $vimeo = new Vimeo();
             $url_descargada = CargaWebCurl($url);
             $vimeo->init($url, $url_descargada);
             $ret = $vimeo->calcula();
             dbug_r($ret);
         } else {
             $adnstream = new Adnstream();
             $url_descargada = CargaWebCurl($url);
             $adnstream->init($url, $url_descargada);
             $ret = $adnstream->calcula();
             dbug_r($ret);
         }
         $obtenido['enlaces'][] = array('titulo' => $ret['titulo']);
         foreach ($ret['enlaces'] as $enlace) {
             $obtenido['enlaces'][] = $enlace;
         }
         if (!isset($obtenido['imagen'])) {
             $obtenido['imagen'] = $ret['imagen'];
         }
     }
     finalCadena($obtenido);
 }
示例#2
0
 function calcula()
 {
     preg_match('@video.php\\?v=(.*?)$@', $this->web, $matches);
     dbug_r($matches);
     if (enString($matches[1], '.mp4')) {
         $url = 'http://www.tvmelilla.es/videoalacarta/' . $matches[1];
         $imagen = strtr($url, array(".mp4" => ".jpg"));
         dbug('imagen = ' . $imagen);
         $titulo = utf8_encode(entre1y2($this->web_descargada, '<title>', '<'));
         dbug('titulo = ' . $titulo);
         $obtenido = array('titulo' => $titulo, 'imagen' => $imagen, 'enlaces' => array(array('url' => $url, 'tipo' => 'http')));
     } else {
         $vimeo = new Vimeo();
         $vimeoURL = 'http://vimeo.com/' . $matches[1];
         $vimeoWeb_descargada = CargaWebCurl($vimeoURL);
         $vimeo->init($vimeoURL, $vimeoWeb_descargada);
         $obtenido = $vimeo->calcula();
     }
     finalCadena($obtenido);
 }
示例#3
0
<?php

/**
 * VOD example using the Official PHP library for the Vimeo API
*/
require_once '../vimeo.php';
if (!function_exists('json_decode')) {
    throw new Exception('We could not find json_decode. json_decode is found in php 5.2 and up, but not found on many linux systems due to licensing conflicts. If you are running ubuntu try "sudo apt-get install php5-json".');
}
$config = json_decode(file_get_contents('./config.json'), true);
if (empty($config['access_token'])) {
    throw new Exception('You can not upload a file without an access token. You can find this token on your app page, or generate one using auth.php');
}
$lib = new Vimeo($config['client_id'], $config['client_secret'], $config['access_token']);
// VOD film example
// Create a new vod page
$create_vod_film = $lib->request('/me/ondemand/pages', array('name' => 'myfilm', 'type' => 'film', 'content_rating' => 'safe', 'link' => 'myfilm', 'dommain_link' => 'myfilm', 'rent' => array('active' => true, 'price' => array('USD' => 5.0), 'period' => '24 hour'), 'buy' => array('active' => true, 'price' => array('USD' => 10.0))), 'POST');
// Set a Genre
$genre = $lib->request('/ondemand/pages/myfilm/genres/art', array(), 'PUT');
// Add a video
$uri = $lib->upload('myvideo.mp4');
$video_data = $lib->request($uri);
$film_video = $lib->request('/ondemand/pages/myfilm' . $video_data['body']['uri'], array('type' => 'main'), 'PUT');
// Add a trailer
$uri = $lib->upload('mytrailer.mp4');
$video_data = $lib->request($uri);
$film_trailer = $lib->request('/ondemand/pages/myfilm' . $video_data['body']['uri'], array('type' => 'trailer'), 'PUT');
// Check to make sure the new video and trailer has been added to the vod page properly
$check_video = $lib->request('/ondemand/pages/myfilm/videos', array('filter' => 'all', 'sort' => 'default'));
print_r($check_video);
// Add a poster to our vod page
示例#4
0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
require_once '../vimeo.php';
if (!function_exists('json_decode')) {
    throw new Exception('We could not find json_decode. json_decode is found in php 5.2 and up, but not found on many linux systems due to licensing conflicts. If you are running ubuntu try "sudo apt-get install php5-json".');
}
$config = json_decode(file_get_contents('./config.json'), true);
if (empty($config['access_token'])) {
    throw new Exception('You can not upload a file without an access token. You can find this token on your app page, or generate one using auth.php');
}
$lib = new Vimeo($config['client_id'], $config['client_secret'], $config['access_token']);
//  Get the args from the command line to see what files to upload.
$files = $argv;
array_shift($files);
//   Keep track of what we have uploaded.
$uploaded = array();
//  Send the files to the upload script.
foreach ($files as $file_name) {
    //  Update progress.
    print 'Uploading ' . $file_name . "\n";
    try {
        //  Send this to the API library.
        $uri = $lib->upload($file_name);
        //  Now that we know where it is in the API, let's get the info about it so we can find the link.
        $video_data = $lib->request($uri);
        //  Pull the link out of successful data responses.
示例#5
0
    $lib = new Vimeo($config['client_id'], $config['client_secret']);
    $tokens = $lib->accessToken($_GET['code'], REDIRECT_URI);
    if ($tokens['status'] == 200) {
        $_SESSION['access_token'] = $tokens['body']->access_token;
        echo 'Successful authentication. Please go to <a href="http://localhost:8080">localhost:8080</a>';
    } else {
        echo "Unsuccessful authentication";
        var_dump($tokens);
    }
} elseif (preg_match('%^/reset%', $_SERVER["REQUEST_URI"])) {
    // Reset url, kill the session and start over
    session_destroy();
    header('Location: http://localhost:8080');
    exit;
} else {
    // Root url, check if the user has already authenticated or not
    if (empty($_SESSION['access_token'])) {
        echo "This is an unauthenticated request to /users/dashron<br />";
        $lib = new Vimeo($config['client_id'], $config['client_secret']);
        $user = $lib->request('/users/dashron');
        $_SESSION['state'] = base64_encode(openssl_random_pseudo_bytes(30));
        echo 'To authenticate you should click <a href="' . $lib->buildAuthorizationEndpoint(REDIRECT_URI, 'public', $_SESSION['state']) . '">here</a><br />';
        var_dump($user);
    } else {
        echo "This is an authenticated request to /me<br />";
        echo 'To start over click <a href="http://localhost:8080/reset">here</a><br />';
        $lib = new Vimeo($config['client_id'], $config['client_secret'], $_SESSION['access_token']);
        $me = $lib->request('/me');
        var_dump($me);
    }
}
示例#6
0
<?php 
$vim = new Vimeo();
//we can assign each api call variable individually
$vim->set_var('_unique_id', 'rww');
$vim->set_var('_api_call', 'channel');
$vim->set_var('_request_name', 'videos');
$vim->set_var('_num_display', 2);
$vim->request();
//for most calls we can stop at request() and do
//what we want with the resulting information.
//For this example though, the class has built in rendering
//for videos.
$vim->render();
//Alternatively we can just ignore the individual variable settings
//and just pass all the arguments into the request() function
$vim = new Vimeo();
$output = $vim->request(array('_api_call' => 'activity', '_unique_id' => 'brad', '_request_name' => 'user_did', '_response_format' => 'json'));
//Do something with the resulting output
//echo '<pre>';
//print_r($output);
//echo '</pre>';
?>

<h2>Accessible Media Testing</h2>
<h3>Vimeo Player</h3>
<div id="vimeo-player" >
        
</div>
<h3>YouTube</h3>
<div id="yt-player" >
        
示例#7
0
<?php

/**
 *   Copyright 2013 Vimeo
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
ini_set('display_errors', 'On');
error_reporting(E_ALL);
require_once '../vimeo.php';
$config = json_decode(file_get_contents('./config.json'), true);
$lib = new Vimeo($config['client_id'], $config['client_secret']);
$user = $lib->request('/users/dashron');
print_r($user);
示例#8
0
<?php

/**
 *   Copyright 2013 Vimeo
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
ini_set('display_errors', 'On');
error_reporting(E_ALL);
require_once '../vimeo.php';
$config = json_decode(file_get_contents('./config.json'), true);
$lib = new Vimeo($config['client_id'], $config['client_secret']);
if (!empty($config['access_token'])) {
    $lib->setToken($config['access_token']);
    $user = $lib->request('/me');
} else {
    $user = $lib->request('/users/dashron');
}
print_r($user);