Code Monkey home page Code Monkey logo

dropbox-v2-php's Introduction

Percentage of issues still open Build Status codecov Dependency Status

Latest Stable Version Total Downloads License

Tested with PHP 5.6-7.1 and HHVM 3.18. See the CI builds page for the most accurate, up-to-date version list.


Maintainer(s) needed!

[10 Feb 2017] Unfortunately, I do not have time to maintain this SDK. I do not expect it to become out-of-date in terms of functionality for at least another year, but it won't be adding any new functionality. Please open an issue if you're interested.


A PHP SDK for Dropbox's v2 API. If you haven't tried Dropbox out yet, do - it's great!

Table of Contents

  1. Installation
  2. Usage
  3. Supported API operations
  4. API Documentation

Installation

Installation is only available via Composer.

Quick version:

composer require alorel/dropbox-v2-php

More informed version:

The package is still in its 0.x development stage, therefore adding it as a ^ dependency, e.g. "alorel/dropbox-v2-php":"^0.1" will severely limit the amount of updates you receive, as, per semver specification, 0.2 is allowed to be backwards-incompatible with 0.1. While I definitely cannot guarantee full backwards compatibility if you fiddle with protected methods and derive your own subclasses, I do guarantee that the public API will remain backwards-compatible, therefore, if you only use the raw methods in your application e.g.

$options = new UploadOptions(); //set your options
(new Upload())->raw('/file.txt', 'data', $options);

You can safely add the following as a dependency in your composer.json:

{
  "require": {
    "alorel/dropbox-v2-php": ">=0.4 <1.0"
  }
}

Additionally, composer outdated is a useful command to know during the 0.x development stage!

Usage

Every Dropbox API operation is located in the \Alorel\Dropbox\Operation namespace and is a class named after the API endpoint. There are a few exceptions to this, however, e.g. the class for https://content.dropboxapi.com/2/files/upload_session/start is \Alorel\Dropbox\Operation\Files\UploadSession\Start.

All operation classes inherit the AbstractOperation constructor:

  /**
    * Operation constructor.
    *
    * @param bool   $async       Whether requests should be asynchronous
    * @param string $accessToken Our access token
    */
    public function __construct($async = null, string $accessToken = null) {}

The first parameter is a boolean determining whether operations should run synchronously or asynchronously (defaults to synchronous), the second is the access token created when the user authorises your application. Both can have default values set via AbstractOperation::setDefaultToken() and AbstractOperation::setDefaultAsync() respectively.

Currently the only supported way of making requests is with the respective operation class' raw method, which will return an instance of PromiseInterface when operating in asynchronous mode or an instance of ResponseInterface if operating in synchronous mode. See guzzlephp.org for more information on promises and responses.

In future releases I will be adding 'management' classes that will automatically format the response.

Supported API Operations

Unless specified otherwise, any operation that is not currently supported will be added in a future release.

Files

All except:

  • /alpha/get_metadata | In Beta/Alpha on Dropbox - will implement once stable
  • /alpha/upload | In Beta/Alpha on Dropbox - will implement once stable
  • /properties/add | In Beta/Alpha on Dropbox - will implement once stable
  • /properties/overwrite | In Beta/Alpha on Dropbox - will implement once stable
  • /properties/remove | In Beta/Alpha on Dropbox - will implement once stable
  • /properties/template/get | In Beta/Alpha on Dropbox - will implement once stable
  • /properties/template/list | In Beta/Alpha on Dropbox - will implement once stable
  • /properties/update | In Beta/Alpha on Dropbox - will implement once stable

Users

All

API Documentation

0.4 | 0.3.3 | 0.2 | 0.1.1 | 0.1


Links

dropbox-v2-php's People

Contributors

alorel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dropbox-v2-php's Issues

About Preview section in RAW Example Code


Issue goes here
Looking at the RAW examples we have the GetPreview functionality where you have mentioned that

// Actually unsure about the content type; should be PDF

Does that mean that the preview works for the Documents only to be previewed as PDF files, and if i need to preview any other file like video, audio or image etc i would have to write my own script to preview those kinds of files by getting a temporary link for that file?

Invalid authorization value in HTTP header

Hi Art,

Can you help me this issue's?

Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: POST https://content.dropboxapi.com/2/files/upload resulted in a 400 Bad Request response: Error in call to API function "files/upload": Invalid authorization value in HTTP header "Authorization": "Bearer 163{" (truncated...) ' in C:\xampp\htdocs\dropbox-v2-php\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php:113 Stack trace: #0 C:\xampp\htdocs\dropbox-v2-php\vendor\guzzlehttp\guzzle\src\Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 C:\xampp\htdocs\dropbox-v2-php\vendor\guzzlehttp\promises\src\Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 C:\xampp\htdocs\dropbox-v2-php\vendor\guzzlehttp\promises\src\Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 C:\xampp\htdocs\dropbox-v2-php\vendor\guzzlehttp\promises\src\TaskQ in C:\xampp\htdocs\dropbox-v2-php\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 113

How to catch error or show status

in this document
https://www.dropbox.com/developers/documentation/http/documentation#files-save_url-check_job_status
by using curl we can have see error in command

curl -X POST https://api.dropboxapi.com/2/files/save_url \
    --header "Authorization: Bearer EXDuL6Bkvc4AAAAAAAABu-ZDfXZ0FRw87e00zjkrDbK2Rw_UpEGqlA-hz_tDgS3W" \
    --header "Content-Type: application/json" \
    --data "{\"path\": \"/a.jpg\",\"url\": \"https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xat1/t51.2885-15/e15/13398575_977722398990188_1841788166_n.jpg
\"}"

image
and now we see error in command
Error in call to API function "files/save_url": request body: could not decode input as JSON
and how to see in browser
I was set ini_set('display_errors', 1);

Conflict Folder Already exists

Hello,

As said in the title I have an issue with your type of return when a folder is already existing, is there a way to "override" your Error Handler without touching your code or do i have to change it ?

Thank you in advance,

Fabricio

"HTTP ERROR 500"

Hi Arl,

I'll review my code i found out this line "(new Finish())->raw($data,$cursor,$commit);" causes an error "HTTP ERROR 500" during testing in linux live server. Can you help me?

Thanks,
Anuar

Authentication examples

Hi,

Thanks for the V2 API implementation!

I have checked examples provided, but I can't find the whole process that includes authentication (including getting the access token - with and without redirection to paste the token back into app asking for access). Am I missing something?

Milan

how use ListFolder?

I , my project have a folder named dropbox2 , inside ther's vendor installed with dropbox , under vendor i create a file list.php with this code

`<?php

use Alorel\Dropbox\Operation\Files\ListFolder\ListFolder;
use Alorel\Dropbox\Operation\Files\ListFolder\ListFolderContinue;
use Alorel\Dropbox\Options\Builder\ListFolderOptions;

function listFolder($folder, ListFolderOptions $options = null) {
    $res = json_decode((new ListFolder())->raw($folder, $options)->getBody()->getContents(), true);

    foreach ($res['entries'] as $i => $e) {
        yield $e['path_lower'] => $e;
        unset($res['entries'][$i]);
    }

    if ($res['has_more']) {
        $more = new ListFolderContinue();

        while ($res['has_more']) {
            $res = json_decode($more->raw($res['cursor'])->getBody()->getContents(), true);

            foreach ($res['entries'] as $i => $e) {
                yield $e['path_lower'] => $e;
                unset($res['entries'][$i]);
            }
        }
    }
}

listFolder('/dentaldropbox');`

but i dont see nothing

installation fails

Hello, I'm trying to install your dropbox api and get the following error. Any ideas?:

fuji:photos root# $PHP5 composer.phar require alorel/dropbox-v2-php
Using version ^0.3.3 for alorel/dropbox-v2-php
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

  • Installing aloframework/common (1.3.3)
    Downloading: 100%
  • Installing psr/http-message (1.0.1)
    Downloading: 100%

Installation failed, reverting ./composer.json to its original content.

[ErrorException]
copy(/santa/home/Allegro/customers/Frantz/photos/vendor/composer/0b15cccd/php-fig-http-message-f6561bf/._CHANGELOG.
md): failed to open stream: No such file or directory

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] []...

fuji:photos root#

hi

Hi, can I use without composer?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.