Install Core API SDKs

To make things as easy as possible, we have several platform SDKs you can import into your development environment to get up and running quickly. The SDKs contain platform-specific libraries that wrap the raw HTTP calls to the Dropbox API. They are designed to shorten the distance between your application and integrating Dropbox.

PHP SDK

The SDK is contained in the lib/ folder in the zip file so copy lib/ into your project and name it dropbox-sdk/ and include it in your app:

require_once "dropbox-sdk/Dropbox/autoload.php";

If you're using Composer for your project's dependencies, you can just add dropbox-sdk to your composer.json instead of downloading the SDK.

"require": {
  "dropbox/dropbox-sdk": "1.1.*"
}

Example scripts

There are a couple sample scripts in the example folder:

  • web-file-browser.php is a basic web app that shows you how to implement the OAuth 2 flow and how to list folders.
  • authorize.php is a command-line tool runs through the OAuth 2 flow and saves the resulting access token to a file.
  • account-info.php uses the access token retrieved by authorize.php to call the /account/info endpoint.

To get these examples running, you'll need provide your app key and secret to the SDK.

The PHP SDK comes with a function to load an API key and secret from a JSON file. For example, create a file called app-info.json with the following contents:

{
  "key": "INSERT_APP_KEY",
  "secret": "INSERT_SECRET"
}

Save this file to the same directory as your app then add this line to your app:

$appInfo = dbx\AppInfo::loadFromJsonFile("config.json");