Easily integrate Dropbox in your PHP application

An inter­est­ing project started less than a week ago, allows any­one to eas­ily inte­grate Drop­box into their PHP appli­ca­tion.
This is an inter­est­ing tool as now any­one who writes PHP appli­ca­tions, can eas­ily pig­gy­back on Drop­box to store data across plat­forms, users, and computers.

The usage is pretty sim­ple, here are a few examples:

Fetch­ing account info:

<?php

/* Please supply your own consumer key and consumer secret */
$consumerKey = '';
$consumerSecret = '';

include 'Dropbox/autoload.php';

session_start();

$dropbox = new Dropbox_API($consumerKey, $consumerSecret);

header('Content-Type: text/plain');

print_r($dropbox->getAccountInfo());

?>

Down­load­ing a file:

<?php

/* Please supply your own consumer key and consumer secret */
$consumerKey = '';
$consumerSecret = '';

include 'Dropbox/autoload.php';

session_start();
$dropbox = new Dropbox_API($consumerKey, $consumerSecret);

header('Content-Type: image/jpeg');
echo $dropbox->getFile('flower.jpg');

?>

Upload­ing a file:

<?php

/* Please supply your own consumer key and consumer secret */
$consumerKey = '';
$consumerSecret = '';

include 'Dropbox/autoload.php';

session_start();
$dropbox = new Dropbox_API($consumerKey, $consumerSecret);

// This method uploads the example script.
if($dropbox->putFile(basename(__FILE__),__FILE__)) {
  echo "Success\n";
}

?>

A few uses I can think of from the top of my head:

  1. For plat­forms such as Word­Press — allow­ing users to have their content/files direc­tory linked directly to their com­puter. Never upload any­thing to your blog/site again, sim­ple save it to your des­ig­nated drop­box folder, and it will instantly show on your site.
  2. Again, in Word­Press like plat­forms, you can setup the themes/plugins direc­tory and edit it directly from your com­puter, and instantly see the changes on the site

If you have any inter­est­ing uses, let me know!

Visit the project web­site: Dropbox-PHP — Drop­box client library for PHP

4 Comments to “Easily integrate Dropbox in your PHP application”

  1. […] Zobacz resztę artykułu: Eli’s » Eas­ily inte­grate Drop­box in your PHP application […]

  2. ultrasound technician 28 May 2010 at 01:47 #

    Valu­able info. Lucky me I found your site by acci­dent, I book­marked it.

  3. physician assistant 29 May 2010 at 03:35 #

    Keep post­ing stuff like this i really like it

  4. ultrasound technician 26 June 2010 at 14:46 #

    Ter­rific work! This is the type of infor­ma­tion that should be shared around the web. Shame on the search engines for not posi­tion­ing this post higher!


Leave a Reply