Vimeo Advanced API for Drupal
- Install the vimeo API on your drupal site.
- Register your site with vimeo and get the Consumer Keys.
- Authorize your site and get the OAuth Tokens.
- Start using the Advanced API for vimeo.
- 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.
- 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
- 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:
- 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
- Save these two codes as you will need them to use the 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.