How to use the PHP API-kit

by Reinier on June 27th, 2008 13:58

To give our users more control over our system we created an API for you to use. This tutorial will show you how to authenticate your application in PHP and contains several example "applications".

Our API kit contains basically 2 files that you need, and a set of files from a PEAR library. How to install and use the kit is what we will explain in this tutorial.

Step 1

Begin by downloading the API kit. Save it in a location where you can easily find it again, such as your desktop.

Step 2

Save and open example file Go to the location where you saved the API kit and unpack it. For Mac OSX users there is native support for unpacking tar.gz files, Windows users can use the free open-source tool 7zip, which can be found at 7-zip.org

Open the folder after unpacking and you should see the botr-php-0.11-example.php file. Open it in a text editor to change the following 2 lines:

$api_key    = '[your api key]';
$api_secret = '[your api secret]';

However, before we can do this we first need to get a new API-key and secret.

Step 3

Go to API keys To get an API-key go to the API tab in our system (login if needed). Here you see a list of applications you have currently allowed access to your account and you also see a list with your own application keys.

Step 4

Fill out API key information We want a new key right now so click on the "Add an API key" to get a new key. This will take you to the API key setup screen. Here you can add the name of your API key, keep in mind that this is also the name other Bits on the Run users will see when they authenticate your application. So if you plan to make your application available to others you should carefully fill in these details.

You can add an optional description and the location to where your application can be found with other documentation (this is normally hosted on your own website).

The last field is important though, the callback URL is the URL the API will send any result data to. For this example please set the callback URL to the location where your botr-php-0.11-example.php can be found when uploaded, if you renamed this file use the updated filename ofcourse.

Finish by clicking "Save key".

Step 5

In the list with your application keys you will now see the key you just created. Use the API key and Secret displayed for your key to replace the values in the botr-php-0.11-example.php.

For example:

$api_key    = 'f75asf88sg89a6af9657f7890f';
$api_secret = '07f065deva9d';

Save the file and upload the entire folder to your webserver (remember to match the location you have specified in the Callback URL as well).

Step 6

Now open a browser and navigate to the botr-php-0.11-example.php file on your server, it should immediately redirect you to the Bits on the Run site asking you to grant your application access to your account.

After clicking yes, you will be forwarded to the URL you specified as the callback. If all goes well you should return to the botr-php-0.11-example.php page which will by default show the text: "Uncomment one of the examples in this PHP file"

Open the botr-php-0.11-example.php to uncomment any of the examples. Now you can start to explore the power given to you through our API.

Please note the 4th example illustrating an upload call: the path referring to the file should be either absolute or relative to the location of the botr-php-0.11-example.php file.

Return to the post overview

Comments

John Penlington

on July 7th, 2008 07:51

Could you make the PHP API file available as a .zip? I tried to open it with 7-zip and didn't get a result.

Roel

on July 11th, 2008 15:54

@John: I think winrar can open the file as well.

downloading movies for backup copies

on August 9th, 2008 22:59

I seen someplace on the site a comment about backing up online videos, but I cant seem to find anyplace on the site that allows you to download the voncerted video file.

JRP Media

on August 11th, 2008 15:39

Could you demonstrate an example of connecting with the API to find out the ID or streaming filename compared to the filename of our original uploaded file? i.e: Uploaded Filename | ID | encoded name jrpmediatextfile.flv | xx | Afy78Qpc7 Thank you,

@JRP Media

on August 14th, 2008 10:31

When you upload a file, its title will be the original filename. So if you search on title without changing it after uploading you are effectively searching on the original filename.

Reinier

on August 14th, 2008 10:38

@ Commenter #3 After the upcoming release, scheduled around September you will be able to download your converted videos from inside the CMS.

Gianluca

on October 30th, 2008 16:16

sorry but I have not understood how to realize a video search with API I use this function find it in examples: $response = $api->callMethod('mediafiles/search', array( 'auth_token' => $token, 'per_page' => 5, 'format' => 'xml', )); but i receive an object how can I extract the name of a video? I have tryed whit: $response->children[0] or foreach($response->children as $rec){ echo $rec[1]; echo $rec[2]; echo $rec[3]; } but it doesn't work

Post your own comment

You need to have javascript enabled to post a comment!

Comment form