Skip to main content

Vimeo Advanced API for Drupal

The Vimeo Advanced API allows the users to access, edit, and upload videos (if approved). With the advanced API, we will be able to create albums, add videos to albums, channels, and groups as well. Let's take a look at what you need to do in order to make the vimeo advanced API work in drupal:
  1. Install the vimeo API on your drupal site.
  2. Register your site with vimeo and get the Consumer Keys.
  3. Authorize your site and get the OAuth Tokens.
  4. Start using the Advanced API for vimeo.
Installing the vimeo API
  • Download the "Advanced API PHP Library" from here
  • Extract the contents of the zip file and move them to a folder called "vimeo" on the root of your drupal website.
Registering the drupal site with Vimeo
  • Login to your vimeo account, and register your website as a new "app" at https://developer.vimeo.com/apps/new
  • Enter the values of required field.
  • Use the URL of your website as the 'Application URL'.
  • Enter the "Application Callback URL", which is very important as the authentication process will start from here.
  • When you are registering an app for the first time, then you may have to wait for a human to authorize the app request.
  • Get your 'Consumer Key' and 'Consumer Secret' and save them to proceed forward.

Authorizing the site to get necessary OAuth tokens

  • Now you need to do one-time authorization of your site.
  • Go to line 6 of vimeo/index.php and replace 'CONSUMER_KEY', 'CONSUMER_SECRET' with their corresponding values obtained in the previous stage
$vimeo = new phpVimeo('CONSUMER_KEY', 'CONSUMER_SECRET');
  • should become something like:
$vimeo = new phpVimeo('2dff4g765w2x9c123fw345cv996543xz', 'z8y76wq123d234b');
  • Around line 60 of vimeo/index.php, there will be a comment "// Set the token". In the next line, you will find
$vimeo->setToken($_SESSION['oauth_access_token'], $_SESSION['oauth_access_token_secret']);
  • Then insert the following code
echo "OAuth access token: ";
echo $_SESSION['oauth_access_token'];
echo "OAuth access token secret: ";
echo $_SESSION['oauth_access_token_secret'];
  • Go to vimeo/index.php page, i.e., the URL which you gave as App Callback URL.
  • Click on the link with text  "Click the link to go to Vimeo to authorize your account."
  • This will take you to Vimeo, where you may need to sign in. You should see:
                     "Do you want to authorize this app? ... Yes, authorize ... "
  • Go ahead and authorize, and if you had entered your callback URL correctly, it should take you back to your index.php.
  • You will see the OAuth access token and token secret
                     OAuth access token: xxxxxxxxxxxxx
                     OAuth access token secret: xxxxxxxxxxxxxxxxx
  • Save these two codes as you will need them to use the advanced API.
Using Vimeo advanced API
  • You have now authorized your website for full access to your vimeo account, and you can now use the API methods.
  • Take a look at the advanced API methods here
  • Do not load vimeo/index.php page again, or else you will end up re-setting your tokens.
  • To call any method in the API, you will the following lines to start with
$vimeo_library_path = DRUPAL_ROOT . '/vimeo';
require_once($vimeo_library_path . '/vimeo.php');
$lib = new phpVimeo(VIMEO_CONSUMER_KEY, VIMEO_CONSUMER_SECRET);
$lib->setToken(VIMEO_OAUTH_TOKEN, VIMEO_OAUTH_SECRET);
$lib->call('method_name', array('parameter_name' => 'paramater_value'));

Hope this blog helps you to use the Advanced vimeo API in your drupal site.

 

Comments

Zach (not verified)

Tue, 11/03/2015 - 07:15

I followed this tutorial but am getting an error saying that i have missed info or the info was invalid, is this due to an update with vimeo or has this worked for other people?