How to use the PHP API-kit
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
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
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
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.
Comments
Roel
downloading movies for backup copies
JRP Media
@JRP Media
Reinier
Gianluca
Post your own comment
You need to have javascript enabled to post a comment!
John Penlington
on July 7th, 2008 07:51