dropbox/dropbox-sdk
最新稳定版本:v1.1.7
Composer 安装命令:
composer require dropbox/dropbox-sdk
包简介
Dropbox SDK for PHP
关键字:
README 文档
README
Do not use this SDK. It relies on Dropbox API v1, which is obsolete.
Alternatives: https://www.dropbox.com/developers/documentation/communitysdks
Dropbox SDK for PHP 5.3+
A PHP library to access Dropbox's HTTP-based API.
License: MIT
Requirements:
- PHP 5.3+, with 64-bit integers.
- PHP cURL extension with SSL enabled (it's usually built-in).
- Must not be using
mbstring.func_overloadto overload PHP's standard string functions.
Setup
If you're using Composer for your project's dependencies, add the following to your "composer.json":
"require": {
"dropbox/dropbox-sdk": "1.1.*"
}
If you're not using Composer, download the code, copy the "lib/" folder into your project somewhere, and include the "lib/Dropbox/autoload.php" in your code. For example, if you copied the "lib/" and named it "dropbox-sdk/", you would do:
// Do this only if you're not using a global autoloader (such as Composer's). require_once "dropbox-sdk/Dropbox/autoload.php";
IMPORTANT: Many PHP installations have an insecure SSL implementation. To check if your PHP installation is insecure, run the included "examples/test-ssl.php" script, either on the command line or via your web server.
Get a Dropbox API key
You need a Dropbox API key to make API requests.
- Go to: https://dropbox.com/developers/apps
- If you've already registered an app, click on the "Options" link to see the app's API key and secret.
- Otherwise, click "Create an app" to register an app. Choose "Dropbox API app", then "Files and datastores", then "Yes" or "No" depending on your needs.
Save the API key to a JSON file called, say, "test.app":
{
"key": "Your Dropbox API app key",
"secret": "Your Dropbox API app secret"
}
Using the Dropbox API
Before your app can access a Dropbox user's files, the user must authorize your application using OAuth 2. Successfully completing this authorization flow gives you an access token for the user's Dropbox account, which grants you the ability to make Dropbox API calls to access their files.
- Authorization example for a simple web app: Web File Browser example
- Authorization example for a command-line tool: Command-Line Authorization example
Once you have an access token, create a Client and start making API calls.
You only need to perform the authorization process once per user. Once you have an access token for a user, save it somewhere persistent, like in a database. The next time that user visits your app, you can skip the authorization process and go straight to making API calls.
Running the Examples and Tests
- Download this repository.
- Save your Dropbox API key in a file called "test.app". See: Get a Dropbox API key, above.
authorize.php
This example runs through the OAuth 2 authorization flow.
./examples/authorize.php test.app test.auth
This produces a file named "test.auth" that has the access token. This file can passed in to the other examples.
account-info.php
A trivial example that calls the /account/info API endpoint.
./examples/account-info.php test.auth
(You must first generate "test.auth" using the "authorize" example above.)
web-file-browser.php
A tiny web app that runs through the OAuth 2 authorization flow and then uses Dropbox API calls to let the user browse their Dropbox files.
Required: copy one of the ".app" files you created previously to "examples/web-file-browser.app".
Using PHP built-in web server (PHP 5.4+).
- Go to the Dropbox API app console, go to the API app you configured in "web-file-browser.app", go to the OAuth redirect URIs section, and add "http://localhost:5000/dropbox-auth-finish".
- Run "
php web-file-browser.php". - Point your browser at "http://localhost:5000/".
Using an existing web server setup.
- Copy the entire SDK folder to your web server's document path. For example, let's say the script is accessible at "http://localhost/~scooby/dropbox/examples/web-file-browser.php".
- Go to the Dropbox API app console, go to the API app you configured in "web-file-browser.app", go to the OAuth redirect URIs section, and add "http://localhost/~scooby/dropbox/examples/web-file-browser.php/dropbox-auth-finish".
- Point your browser at "http://localhost/~scooby/dropbox/examples/web-file-browser.php".
Running the Tests
- run:
composer install --devto download the dependencies. (You'll need Composer.) - Put an "auth info" file in "test/test.auth". (You can generate "test/test.auth" using the "authorize.php" example script.)
./vendor/bin/phpunit test/
dropbox/dropbox-sdk 适用场景与选型建议
dropbox/dropbox-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.23M 次下载、GitHub Stars 达 229, 最近一次更新时间为 2013 年 02 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「dropbox」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dropbox/dropbox-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dropbox/dropbox-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dropbox/dropbox-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A simple database backup manager for Symfony2 with support for S3, Rackspace, Dropbox, FTP, SFTP.
Dropbox PHP API V2 SDK (Unofficial)
Set of tools for Roundcube webmail
Dropbox PHP API V2 SDK (Unofficial)
NinjaImg PHP SDK.
Filesystem abstraction: Many filesystems, one API. Refactored for Legacy PHP 5.3
统计信息
- 总下载量: 1.23M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 241
- 点击次数: 16
- 依赖项目数: 28
- 推荐数: 3
其他信息
- 授权协议: MIT
- 更新时间: 2013-02-16