<?php

require_once 'Vimeo.class.php';
session_start();
$API_KEY = '35ed7eb555a35448563c62ce9670628e';
$API_SECRET = '6ea19082a070bbf';
$video_file = !empty($_REQUEST['v']) ? htmlentities($_REQUEST['v']) : 'test.mp4';
// Create the object and enable caching
$vimeo = new phpVimeo($API_KEY, $API_SECRET);
//enter your API_KEY and API_SECRET_KEY here
$vimeo->enableCache(phpVimeo::CACHE_FILE, './cache', 300);
// Clear session
if ($_GET['clear'] == 'all') {
    session_destroy();
    session_start();
}
// Set up variables
$state = $_SESSION['vimeo_state'];
$request_token = $_SESSION['oauth_request_token'];
$access_token = $_SESSION['oauth_access_token'];
// Coming back
if ($_REQUEST['oauth_token'] != NULL && $_SESSION['vimeo_state'] === 'start') {
    $_SESSION['vimeo_state'] = $state = 'returned';
}
// If we have an access token, set it
if ($_SESSION['oauth_access_token'] != null) {
    $vimeo->setToken($_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);
}
switch ($_SESSION['vimeo_state']) {
    default:
        // Get a new request token