Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
696 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Vimeo PHP OAuth Library | ||
Last updated: 8/14/10 | ||
|
||
Changelog: | ||
08/14/10 - add replace video for upload API, fix chunk cleanup | ||
06/30/10 - update to new chunk upload method | ||
05/07/10 - explicitly set separator for http_build_query when building base string | ||
02/04/10 - fixed parameter encoding issue | ||
12/16/09 - fixed another callback url bug | ||
12/11/09 - fixed base string url encoding issue | ||
11/24/09 - removed manifest from single-file upload | ||
- added exception class | ||
- use Authorization header for OAuth params by default | ||
- fixed caching | ||
11/04/09 - default callback url to "oob" | ||
10/29/09 - fixed callback url bug | ||
10/16/09 - added callback url support to getAuthorizeUrl() | ||
10/15/09 - added OAuth support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
require_once('vimeo.php'); | ||
session_start(); | ||
|
||
// Create the object and enable caching | ||
$vimeo = new phpVimeo('CONSUMER_KEY', 'CONSUMER_SECRET'); | ||
$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 | ||
$token = $vimeo->getRequestToken(); | ||
|
||
// Store it in the session | ||
$_SESSION['oauth_request_token'] = $token['oauth_token']; | ||
$_SESSION['oauth_request_token_secret'] = $token['oauth_token_secret']; | ||
$_SESSION['vimeo_state'] = 'start'; | ||
|
||
// Build authorize link | ||
$authorize_link = $vimeo->getAuthorizeUrl($token['oauth_token'], 'write'); | ||
|
||
break; | ||
|
||
case 'returned': | ||
|
||
// Store it | ||
if ($_SESSION['oauth_access_token'] === NULL && $_SESSION['oauth_access_token_secret'] === NULL) { | ||
// Exchange for an access token | ||
$vimeo->setToken($_SESSION['oauth_request_token'], $_SESSION['oauth_request_token_secret']); | ||
$token = $vimeo->getAccessToken($_REQUEST['oauth_verifier']); | ||
|
||
// Store | ||
$_SESSION['oauth_access_token'] = $token['oauth_token']; | ||
$_SESSION['oauth_access_token_secret'] = $token['oauth_token_secret']; | ||
$_SESSION['vimeo_state'] = 'done'; | ||
|
||
// Set the token | ||
$vimeo->setToken($_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']); | ||
} | ||
|
||
// Do an authenticated call | ||
try { | ||
$videos = $vimeo->call('vimeo.videos.getUploaded'); | ||
} | ||
catch (VimeoAPIException $e) { | ||
echo "Encountered an API error -- code {$e->getCode()} - {$e->getMessage()}"; | ||
} | ||
|
||
break; | ||
} | ||
|
||
?> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
<title>Vimeo Advanced API OAuth Example</title> | ||
</head> | ||
<body> | ||
|
||
<h1>Vimeo Advanced API OAuth Example</h1> | ||
<p>This is a basic example of Vimeo's new OAuth authentication method. Everything is saved in session vars, so <a href="?clear=all">click here if you want to start over</a>.</p> | ||
|
||
<?php if ($_SESSION['vimeo_state'] == 'start'): ?> | ||
<p>Click the link to go to Vimeo to authorize your account.</p> | ||
<p><a href="<?= $authorize_link ?>"><?php echo $authorize_link ?></a></p> | ||
<?php endif ?> | ||
|
||
<?php if ($ticket): ?> | ||
<pre><?php print_r($ticket) ?></pre> | ||
<?php endif ?> | ||
|
||
<?php if ($videos): ?> | ||
<pre><?php print_r($videos) ?></pre> | ||
<?php endif ?> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
h1. Vimeo Advanced API PHP Library | ||
|
||
This library is all set to go with version 2 of our API. Just create the object and call a method like this: | ||
|
||
<pre>$vimeo = new phpVimeo('your consumer key', 'your consumer secret'); | ||
$videos = $vimeo->call('vimeo.videos.getUploaded', array('user_id' => 'brad'));</pre> | ||
|
||
The <code>index.php</code> file included will show you how to get an access token so that you can query the API for private items. To take a look at an example of how to upload a file, check out <code>upload.php</code>. | ||
|
||
h2. Support | ||
|
||
If you come across any bugs, or have any suggestions, please post them in our "API Forum":http://www.vimeo.com/forum:API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
include 'vimeo.php'; | ||
|
||
$vimeo = new phpVimeo('CONSUMER_KEY', 'CONSUMER_SECRET', 'ACCESS_TOKEN', 'ACCESS_TOKEN_SECRET'); | ||
|
||
try { | ||
$video_id = $vimeo->upload('PATH_TO_VIDEO_FILE'); | ||
|
||
if ($video_id) { | ||
echo '<a href="http://vimeo.com/' . $video_id . '">Upload successful!</a>'; | ||
|
||
//$vimeo->call('vimeo.videos.setPrivacy', array('privacy' => 'nobody', 'video_id' => $video_id)); | ||
$vimeo->call('vimeo.videos.setTitle', array('title' => 'YOUR TITLE', 'video_id' => $video_id)); | ||
$vimeo->call('vimeo.videos.setDescription', array('description' => 'YOUR_DESCRIPTION', 'video_id' => $video_id)); | ||
} | ||
else { | ||
echo "Video file did not exist!"; | ||
} | ||
} | ||
catch (VimeoAPIException $e) { | ||
echo "Encountered an API error -- code {$e->getCode()} - {$e->getMessage()}"; | ||
} |
Oops, something went wrong.