harrisonhjones/phpDropboxApi
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
_ ___ _ _____
( ) ( _`\ ( ) ( _ ) _
_ _ | |__ _ _ | | ) | _ __ _ _ _ | |_ _ | (_) | _ _ (_)
( '_`\ | _ `\( '_`\ | | | )( '__)/'_`\ ( '_`\ | '_`\ /'_`\ (`\/')| _ |( '_`\ | |
| (_) )| | | || (_) )| |_) || | ( (_) )| (_) )| |_) )( (_) ) > < | | | || (_) )| |
| ,__/'(_) (_)| ,__/'(____/'(_) `\___/'| ,__/'(_,__/'`\___/'(_/\_)(_) (_)| ,__/'(_)
| | | | | | | |
(_) (_) (_) (_)
About
******************
phpDropboxApi is a PHP class which can be used to interact with Dropbox in a manner that is similar to the oficial Dropbox API.
NOTE: THIS IS NOT A DROP-IN REPLACEMENT FOR THE OFFICIAL DROPBOX API PHP CLASS.
It was created by Harrison Jones [harrison@harrisonhjones.com] [http://harrisonhjones.com/projects/phpDropboxApi]
You can use it to:
* Retrieve Dropbox account info such as your quota and your current usage
* Upload a file to any Dropbox folder
* Delete files from any Dropbox folder
* Create a public link for any file in your "Public" Dropbox folder
* Move files
* Copy Files
* Create a folder
Usage
******************
**Basic Setup
require 'Dropbox.php';
$db = new Dropbox('email@address.com', 'password');
**Retrieving Account Infomation
$account = $db->account();
echo "UserID: " . $account->uid . "\n";
echo "Percent Quota Used: " . $account->quotaPercentUsed . "\n";
echo "Quota Used: " . $account->quotaUsed . "\n";
echo "Quota: " . $account->quota . "\n";
// The following are approximations. The above data is more exact
echo "RegularUsed: " . $account->regularUsed . "\n";
echo "SharedUsed: " . $account->sharedUsed . "\n";
echo "Unused: " . $account->unused . "\n";
**Uploading a File
try
{
$db->upload('readme.txt',"Public");
echo "File uploaded";
}
catch (Exception $e)
{
echo 'File upload exception: ' . $e->getMessage() . "<BR/>";
}
**Deleting Files
try
{
$del = $db->delete(array('/FOLDER/FILE','/FOLDER2/FILE2'));
echo "File deleted";
}
catch (Exception $e)
{
echo 'File delete exception: ' . $e->getMessage() . "<BR/>";
}
**Creating a Public Link
echo "Link available at : " . $db->publicLink('readme.txt'); //NOTE: ONLY CREATES VALID PUBLIC LINKS FOR FILES IN THE PUBLIC FOLDER!
**Coping Files
try
{
$cpy = $db->copy(array('/fromFOLDER/fromFILE','/fromFOLDER2/fromFILE2'),'/toFOLDER');//
echo "File copied";
}
catch (Exception $e)
{
echo 'File copy exception: ' . $e->getMessage() . "<BR/>";
}
**Moving Files
try
{
$mv = $db->move(array('/fromFOLDER/fromFILE','/fromFOLDER2/fromFILE2'),'/toFOLDER');//
echo "File moved";
}
catch (Exception $e)
{
echo 'File copy exception: ' . $e->getMessage() . "<BR/>";
}
**Creating a Folder
$mv = $db->create('folderName','/path/to/root/folder');
License
******************
phpDropboxApi is licensed under the MIT License. I only ask that you drop me an email explaining how you plan on using this class. I'm simply curious!
Trobleshooting
******************
No issues yet. Drop me an email if you find one (or fork the project and fix it yourself).
ToDo
******************
* Clean up
Version history
******************
1.0.0 - Initial release.
1.0.1 - Added Copy and Move functions. Delete now deletes multiple files
1.0.2 - Added create function for folder creation