PHP Class TijsVerkoyen\Dropbox\Dropbox

Author: Tijs Verkoyen ([email protected])
Datei anzeigen Open project: tijsverkoyen/dropbox Class Usage Examples

Public Methods

Method Description
__construct ( string $applicationKey, string $applicationSecret ) Default constructor
__destruct ( ) Default destructor
accountInfo ( ) : array Retrieves information about the user's account.
copyRef ( string $path, bool[optional] $sandbox = false ) : array Creates and returns a copy_ref to a file. This reference string can be used to copy that file to another user's Dropbox by passing it in as the fromCopyRef parameter on fileopsCopy.
delta ( string[optional] $cursor = null, string[optional] $locale = null ) : array A way of letting you keep up with changes to files and folders in a user's Dropbox. You can periodically call /delta to get a list of "delta entries", which are instructions on how to update your local state to match the server's state.
fileopsCopy ( string[optional] $fromPath = null, string $toPath, string[optional] $fromCopyRef = null, string[optional] $locale = null, bool[optional] $sandbox = false ) : array Copies a file or folder to a new location.
fileopsCreateFolder ( string $path, string[optional] $locale = null, bool[optional] $sandbox = false ) : array Creates a folder.
fileopsDelete ( string $path, string[optional] $locale = null, bool[optional] $sandbox = false ) : array Deletes a file or folder.
fileopsMove ( string $fromPath, string $toPath, string[optional] $locale = null, bool[optional] $sandbox = false ) : array Moves a file or folder to a new location.
filesGet ( string $path, string[optional] $rev = null, bool[optional] $sandbox = false ) : array Downloads a file.
filesPost ( string $path, string $localFile, bool[optional] $overwrite = null, string[optional] $parentRev = null, $locale = null, bool[optional] $sandbox = false ) : array Uploads a file.
getTimeOut ( ) : integer Get the timeout
getUserAgent ( ) : string Get the useragent that will be used.
media ( string $path, string[optional] $locale = null, bool[optional] $sandbox = false ) : array Returns a link directly to a file.
metadata ( string[optional] $path = '', int[optional] $fileLimit = 10000, string[optional] $hash = false, bool[optional] $list = true, bool[optional] $includeDeleted = false, string[optional] $rev = null, string[optional] $locale = null, bool[optional] $sandbox = false ) : array Retrieves file and folder metadata.
oAuthAccessToken ( string $oauthToken ) : array Step 3 of authentication. After the /oauth/authorize step is complete, the application can call /oauth/access_token to acquire an access token.
oAuthAuthorize ( string $oauthToken, string[optional] $oauthCallback = null, string[optional] $locale = null ) Step 2 of authentication. Applications should direct the user to /oauth/authorize. This isn't an API call per se, but rather a web endpoint that lets the user sign in to Dropbox and choose whether to grant the application the ability to access files on their behalf. The page served by /oauth/authorize should be presented to the user through their web browser. Without the user's authorization in this step, it isn't possible for your application to obtain an access token from /oauth/access_token.
oAuthRequestToken ( ) : array Step 1 of authentication. Obtain an OAuth request token to be used for the rest of the authentication process.
restore ( string $path, string $rev, string[optional] $locale = null, bool[optional] $sandbox = false ) : array Restores a file path to a previous revision.
revisions ( string $path, int[optional] $revLimit = 10, string[optional] $locale = null, bool[optional] $sandbox = false ) : array Obtains metadata for the previous revisions of a file.
search ( string $path, string $query, int[optional] $fileLimit = 1000, bool[optional] $includeDeleted = null, string[optional] $locale = null, bool[optional] $sandbox = false ) : array Returns metadata for all files and folders whose filename contains the given search string as a substring.
setOAuthToken ( string $token ) Set the oAuth-token
setOAuthTokenSecret ( string $secret ) Set the oAuth-secret
setTimeOut ( integer $seconds ) Set the timeout
setUserAgent ( string $userAgent ) Get the useragent that will be used.
shares ( string $path, boolean $shortUrl = true, string[optional] $locale = null, bool[optional] $sandbox = false ) : array Creates and returns a Dropbox link to files or folders users can use to view a preview of the file in a web browser.
thumbnails ( string[optional] $path, string[optional] $size = 'small', string[optional] $format = 'jpeg', bool[optional] $sandbox = false ) : string Gets a thumbnail for an image.

Private Methods

Method Description
buildQuery ( array $parameters ) : string Format the parameters as a querystring
calculateHeader ( array $parameters, string $url ) : string Build the Authorization header
doCall ( string $url, array $parameters = null, string[optional] $method = 'GET', $filePath = null, $expectJSON = true, $isContent = false ) : string Make the call
doOAuthCall ( string $url, array $parameters = null, string[optional] $method = 'POST', bool[optional] $expectJSON = true ) : mixed Make an call to the oAuth
getApplicationKey ( ) : string Get the application key
getApplicationSecret ( ) : string Get the application secret
getOAuthToken ( ) : string Get the oAuth-token
getOAuthTokenSecret ( ) : string Get the oAuth-token-secret
setApplicationKey ( string $key ) Set the application key
setApplicationSecret ( string $secret ) Set the application secret
urlencode_rfc3986 ( mixed $value ) : string URL-encode method for internal use

Method Details

__construct() public method

Default constructor
public __construct ( string $applicationKey, string $applicationSecret )
$applicationKey string The application key to use.
$applicationSecret string The application secret to use.

__destruct() public method

Default destructor
public __destruct ( )

accountInfo() public method

Retrieves information about the user's account.
public accountInfo ( ) : array
return array

copyRef() public method

Creates and returns a copy_ref to a file. This reference string can be used to copy that file to another user's Dropbox by passing it in as the fromCopyRef parameter on fileopsCopy.
public copyRef ( string $path, bool[optional] $sandbox = false ) : array
$path string The path to the file.
$sandbox bool[optional]
return array

delta() public method

A way of letting you keep up with changes to files and folders in a user's Dropbox. You can periodically call /delta to get a list of "delta entries", which are instructions on how to update your local state to match the server's state.
public delta ( string[optional] $cursor = null, string[optional] $locale = null ) : array
$cursor string[optional]
$locale string[optional]
return array

fileopsCopy() public method

Copies a file or folder to a new location.
public fileopsCopy ( string[optional] $fromPath = null, string $toPath, string[optional] $fromCopyRef = null, string[optional] $locale = null, bool[optional] $sandbox = false ) : array
$fromPath string[optional]
$toPath string Specifies the destination path, including the new name for the file or folder, relative to root.
$fromCopyRef string[optional]
$locale string[optional]
$sandbox bool[optional]
return array

fileopsCreateFolder() public method

Creates a folder.
public fileopsCreateFolder ( string $path, string[optional] $locale = null, bool[optional] $sandbox = false ) : array
$path string The path to the new folder to create relative to root.
$locale string[optional]
$sandbox bool[optional]
return array

fileopsDelete() public method

Deletes a file or folder.
public fileopsDelete ( string $path, string[optional] $locale = null, bool[optional] $sandbox = false ) : array
$path string The path to the file or folder to be deleted.
$locale string[optional]
$sandbox bool[optional]
return array

fileopsMove() public method

Moves a file or folder to a new location.
public fileopsMove ( string $fromPath, string $toPath, string[optional] $locale = null, bool[optional] $sandbox = false ) : array
$fromPath string Specifies the file or folder to be moved from relative to root.
$toPath string Specifies the destination path, including the new name for the file or folder, relative to root.
$locale string[optional]
$sandbox bool[optional]
return array

filesGet() public method

Downloads a file.
public filesGet ( string $path, string[optional] $rev = null, bool[optional] $sandbox = false ) : array
$path string The path to the file you want to retrieve.
$rev string[optional]
$sandbox bool[optional]
return array An array with the content-type and the data as a base64-encoded string.

filesPost() public method

Uploads a file.
public filesPost ( string $path, string $localFile, bool[optional] $overwrite = null, string[optional] $parentRev = null, $locale = null, bool[optional] $sandbox = false ) : array
$path string The path to the folder the file should be uploaded to. This parameter should not point to a file.
$localFile string The path to the local file.
$overwrite bool[optional]
$parentRev string[optional]
$sandbox bool[optional]
return array

getTimeOut() public method

Get the timeout
public getTimeOut ( ) : integer
return integer

getUserAgent() public method

Our version will be prepended to yours. It will look like: "PHP Dropbox/ "
public getUserAgent ( ) : string
return string

media() public method

Returns a link directly to a file.
public media ( string $path, string[optional] $locale = null, bool[optional] $sandbox = false ) : array
$path string The path to the file.
$locale string[optional]
$sandbox bool[optional]
return array

metadata() public method

Retrieves file and folder metadata.
public metadata ( string[optional] $path = '', int[optional] $fileLimit = 10000, string[optional] $hash = false, bool[optional] $list = true, bool[optional] $includeDeleted = false, string[optional] $rev = null, string[optional] $locale = null, bool[optional] $sandbox = false ) : array
$path string[optional]
$fileLimit int[optional]
$hash string[optional]
$list bool[optional]
$includeDeleted bool[optional]
$rev string[optional]
$locale string[optional]
$sandbox bool[optional]
return array

oAuthAccessToken() public method

This method corresponds to Obtaining an Access Token in the OAuth Core 1.0 specification.
public oAuthAccessToken ( string $oauthToken ) : array
$oauthToken string The token returned after authorizing.
return array

oAuthAuthorize() public method

This method corresponds to Obtaining User Authorization in the OAuth Core 1.0 specification.
public oAuthAuthorize ( string $oauthToken, string[optional] $oauthCallback = null, string[optional] $locale = null )
$oauthToken string The request token obtained via /oauth/request_token.
$oauthCallback string[optional]
$locale string[optional]

oAuthRequestToken() public method

This method corresponds to Obtaining an Unauthorized Request Token in the OAuth Core 1.0 specification. A request token and the corresponding request token secret, URL-encoded. This token/secret pair is meant to be used with /oauth/access_token to complete the authentication process and cannot be used for any other API calls. See Service Provider Issues an Unauthorized Request Token in the OAuth Core 1.0 specification for additional discussion of the values returned when fetching a request token.
public oAuthRequestToken ( ) : array
return array

restore() public method

Unlike downloading a file at a given revision and then re-uploading it, this call is atomic. It also saves a bunch of bandwidth.
public restore ( string $path, string $rev, string[optional] $locale = null, bool[optional] $sandbox = false ) : array
$path string The path to the file.
$rev string The revision of the file to restore.
$locale string[optional]
$sandbox bool[optional]
return array

revisions() public method

Only revisions up to thirty days old are available (or more if the Dropbox user has Pack-Rat). You can use the revision number in conjunction with the /restore call to revert the file to its previous state.
public revisions ( string $path, int[optional] $revLimit = 10, string[optional] $locale = null, bool[optional] $sandbox = false ) : array
$path string The path to the file.
$revLimit int[optional]
$locale string[optional]
$sandbox bool[optional]
return array

setOAuthToken() public method

Set the oAuth-token
public setOAuthToken ( string $token )
$token string The token to use.

setOAuthTokenSecret() public method

Set the oAuth-secret
public setOAuthTokenSecret ( string $secret )
$secret string The secret to use.

setTimeOut() public method

Set the timeout
public setTimeOut ( integer $seconds )
$seconds integer The timeout in seconds.

setUserAgent() public method

Our version will be prepended to yours. It will look like: "PHP Dropbox/ "
public setUserAgent ( string $userAgent )
$userAgent string The user-agent, it should look like /.

shares() public method

Creates and returns a Dropbox link to files or folders users can use to view a preview of the file in a web browser.
public shares ( string $path, boolean $shortUrl = true, string[optional] $locale = null, bool[optional] $sandbox = false ) : array
$path string The path to the file.
$shortUrl boolean When true (default), the url returned will be shortened using the Dropbox url shortener. If false, the url will link directly to the file's preview page.
$locale string[optional]
$sandbox bool[optional]
return array

thumbnails() public method

Gets a thumbnail for an image.
public thumbnails ( string[optional] $path, string[optional] $size = 'small', string[optional] $format = 'jpeg', bool[optional] $sandbox = false ) : string
$path string[optional]
$size string[optional]
$format string[optional]
$sandbox bool[optional]
return string An array with the content-type and the data as a base64-encoded string.