/** * 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 $response = $lib->uploadImage('/ondemand/pages/myfilm/pictures', './test.png');
} $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. $link = ''; if ($video_data['status'] == 200) { $link = $video_data['body']['link']; } // Store this in our array of complete videos. $uploaded[] = array('file' => $file_name, 'api_video_uri' => $uri, 'link' => $link); } catch (VimeoUploadException $e) { // We may have had an error. We can't resolve it here necessarily, so report it to the user. print 'Error uploading ' . $file_name . "\n"; print 'Server reported: ' . $e->getMessage() . "\n"; } } // Provide a summary on completion with links to the videos on the site. print 'Uploaded ' . count($uploaded) . " files.\n\n";
$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" > </div>
$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); } }
<?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);