Skip to content

Working with User Accounts

Kunal Varma edited this page Jun 30, 2016 · 6 revisions

Working with User Accounts

Get Current Account

Get current authorized user's account.

Example

$account = $dropbox->getCurrentAccount();

//Id
$account->getAccountId();

//Name
$account->getDisplayName();

//Email
$account->getEmail();

//Profile Pic URL
$account->getProfilePhotoUrl();

//Account Type
$account->getAccountType();

The getCurrentAccount() method will return an instance of the Account model.

For details & available options see: https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account

Get Account

Get a User's account.

Example

$accountId = "dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc";
$account = $dropbox->getAccount($accountId);

//Id
$account->getAccountId();

//Name
$account->getDisplayName();

//Email
$account->getEmail();

//Profile Pic URL
$account->getProfilePhotoUrl();

//Account Type
$account->getAccountType();

The getAccount() method will return an instance of the Account model.

For details & available options see: https://www.dropbox.com/developers/documentation/http/documentation#users-get_account

Get Batch Account

Get multiple accounts.

Example

$accountIds = [
"dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc",
"dbid:AADRW_KJHkjHihoi8iujbJ78nmbB8jbKB98",
"dbid:AAH7e48H2kapNKb-OaONIbNQRop6ywGQngc",
];

$accounts = $dropbox->getAccounts($accountIds);

//All Accounts
$accounts->all();

//First Account
$account = $accounts->first();

//Name
$account->getDisplayName();

The getAccounts() method will return an instance of the AccountList model which extends the ModelCollection model.

For details & available options see: https://www.dropbox.com/developers/documentation/http/documentation#users-get_account_batch

Get Space Usage

Get Space Usage for the current user's account

Example

$accountSpace = $dropbox->getSpaceUsage();

//Space Used
$used = $accountSpace['used'];

//Space Allocated
$allocated = $accountSpace['allocated'];

The getSpaceUsage() method will return an array with the account's space usage details. Here's a sample response:

{
    "used": 314159265,
    "allocation": {
        ".tag": "individual",
        "allocated": 10000000000
    }
}

For details & available options see: https://www.dropbox.com/developers/documentation/http/documentation#users-get_space_usage

<< Detailed Usage Guide