Dropbox class

__construct

Default constructor

Parameters

applicationKey string
The application key to use.
applicationSecret string
The application secret to use.

Return

void

__destruct

Default destructor

Return

void

setOAuthToken

Set the oAuth-token

Parameters

token string
The token to use.

Return

void

setOAuthTokenSecret

Set the oAuth-secret

Parameters

secret string
The secret to use.

Return

void

setTimeOut

Set the timeout

Parameters

seconds int
The timeout in seconds.

Return

void

setUserAgent

Get the useragent that will be used. Our version will be prepended to yours.
It will look like: "PHP Dropbox/<version> <your-user-agent>"

Parameters

userAgent string
Your user-agent, it should look like <app-name>/<app-version>.

Return

void

oAuthRequestToken

Call for obtaining an OAuth request token.
Returns a request token and the corresponding request token secret. This token and secret cannot be used to sign requests for the /metadata and /file content API calls.
Their only purpose is for signing a request to oauth/access_token once the user has gone through the application authorization steps provided by oauth/authorize.

Return

array

oAuthAuthorize

Redirect the user to the oauth/authorize location so that Dropbox can authenticate the user and ask whether or not the user wants to authorize the application to access
file metadata and content on its behalf. oauth/authorize is not an API call per se, because it does not have a return value, but rather directs the user to a page on
api.dropbox.com where they are provided means to log in to Dropbox and grant authority to the application requesting it.
The page served by oauth/authorize should be presented to the user through their web browser.
Please note, without directing the user to a Dropbox-provided page via oauth/authorize, it is impossible for your application to use the request token it received
via oauth/request_token to obtain an access token from oauth/access_token.

Parameters

oauthToken string
The request token of the application requesting authority from a user.
oauthCallback string (optional)
After the user authorizes an application, the user is redirected to the application-served URL provided by this parameter.

Return

void

oAuthAccessToken

This call returns a access token and the corresponding access token secret.
Upon return, the authorization process is now complete and the access token and corresponding secret are used to sign requests for the metadata and file content API calls.

Parameters

oauthToken string
The token returned after authorizing.

Return

array

token

The token call provides a consumer/secret key pair you can use to consistently access the user's account.
This is the preferred method of authentication over storing the username and password.
Use the key pair as a signature with every subsequent call.
The request must be signed using the application's developer and secret key token. Request or access tokens are necessary.
Warning: DO NOT STORE THE USER'S PASSWORD! The way this call works is you call it once with the user's email and password and then
keep the token around for later. You do NOT (I repeat NOT) call this before everything you do or on each program startup.
We watch for this and will shut down your application with little notice if we catch you.
In fact, the Objective-C code does this for you so you can't get it wrong.

Parameters

email string
The email account of the user.
password string
The password of the user.

Return

array Upon successful verification of the user's credentials, returns an array representation of the access token and secret.

account

Given a set of account information, the account call allows an application to create a new Dropbox user account.
This is useful for situations where the trusted third party application is possibly the user's first interaction with Dropbox.

Parameters

email string
The email account of the user.
password string
The password for the user.
firstName string
The user's first name.
lastName string
The user's last name.

Return

bool

accountInfo

Get the user account information.

Return

array

filesGet

Retrieves file contents relative to the user's Dropbox root or the application's directory within the user's Dropbox.

Parameters

path string
Path of the directory wherin the file is located.
sandbox bool (optional)
Sandbox mode?

Return

string

filesPost

Uploads file contents relative to the user's Dropbox root or the application's directory within the user's Dropbox.

Parameters

path string
Path of the directory wherin the file should be uploaded.
localFile string
Path to the local file.
sandbox bool (optional)
Sandbox mode?

Return

bool

metadata

Returns metadata for the file or directory at the given <path> location relative to the user's Dropbox or
the user's application sandbox. If <path> represents a directory and the list parameter is true, the metadata will
also include a listing of metadata for the directory's contents.

Parameters

path string (optional)
The path to the file/director to get the metadata for.
fileLimit int (optional)
When listing a directory, the service will not report listings containing more than $fileLimit files.
hash bool (optional)
Listing return values include a hash representing the state of the directory's contents.
list bool (optional)
If true, this call returns a list of metadata representations for the contents of the directory. If false, this call returns the metadata for the directory itself.
sandbox bool (optional)
Sandbox mode?

Return

array

thumbnails

Get a minimized thumbnail for a photo.

Parameters

path string
The path to the photo.
size string (optional)
The size, possible values are: 'small' (32x32), 'medium' (64x64), 'large' (128x128).

Return

string Will return a base64_encode string with the JPEG-data

fileopsCopy

Copy a file or folder to a new location.

Parameters

fromPath string
fromPath specifies either a file or folder to be copied to the location specified by toPath. This path is interpreted relative to the location specified by root.
toPath string
toPath specifies the destination path including the new name for file or folder. This path is interpreted relative to the location specified by root.
sandbox bool (optional)
Sandbox mode?

Return

array

fileopsCreateFolder

Create a folder relative to the user's Dropbox root or the user's application sandbox folder.

Parameters

path string
The path to the new folder to create, relative to root.
sandbox bool (optional)
Sandbox mode?

Return

array

fileopsDelete

Deletes a file or folder.

Parameters

path string
path specifies either a file or folder to be deleted. This path is interpreted relative to the location specified by root.
sandbox bool (optional)
Sandbox mode?

Return

array

fileopsMove

Move a file or folder to a new location.

Parameters

fromPath string
fromPath specifies either a file or folder to be copied to the location specified by toPath. This path is interpreted relative to the location specified by root.
toPath string
toPath specifies the destination path including the new name for file or folder. This path is interpreted relative to the location specified by root.
sandbox bool (optional)
Sandbox mode?

Return

array

About me?

Well, I'm Tijs Verkoyen, a self employed Belgian PHP-developer at Sumo Coders.

If you want to know more about me, check my blog (Dutch).

If you really like my work and want to support me, feel free to use the donate-button below.

Spoon

At both companies, we use Spoon. Spoon is a PHP5 Library that we use for building all our Web 2.0 applications.

The classes that you can download from this website are standalone, so each developer is free to use a library/framework/… he likes best.