Coder Social home page Coder Social logo

jimdoescode / codeigniter-dropbox-api-library Goto Github PK

View Code? Open in Web Editor NEW
154.0 17.0 58.0 1.3 MB

This library is written for the CodeIgniter PHP framework and is meant to interact with the Dropbox API

Home Page: http://jimdoescode.blogspot.com/2011/07/codeigniter-dropbox-api.html

PHP 100.00%

codeigniter-dropbox-api-library's Introduction

CodeIgniter Dropbox API Library

This library will let a user authenticate with dropbox and perform actions such as uploading files, moving files, and deleting files from their dropbox account.

Basic documentation can be found on my blog at http://jimdoescode.blogspot.com

The example controller provided will also give you a good idea of how to authenticate and use the library.

Usage

Copy the files under your application directory. Then load the library like this:

$params['key'] = 'YOUR DROPBOX CONSUMER KEY';

$params['secret'] = 'YOUR DROPBOX CONSUMER SECRET';

$this->load->library('dropbox', $params);

$dbobj = $this->dropbox->account();

License

This library is licensed under the MIT license.

Sparks

You can also use this library with Sparks. Simply install using sparks then call.

$this->load->spark('dropbox/1.0.0');

Then load the library as specified in the usage.

codeigniter-dropbox-api-library's People

Contributors

72quadrat avatar cakoose avatar jimdoescode 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  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

codeigniter-dropbox-api-library's Issues

Url Encode Special Chars in path

There are only white spaces in filenames or foldernames url encoded like this:
$path = str_replace(' ', '%20', $path);

so folders or filenames with umlauts, or other special characters won't work
better do it this way the other way around:
$path = str_replace('%2F', '/', urlencode($path));

What it does it, that everything get's urlencoded and after it the slashes get back to real slashes.

I had big issues with german umlauts in filenames.

Upload Issue

Hi,

I am having an issue when using
$dbobj = $this->dropbox->add("clients","test.txt", $params, "sandbox");
var_dump($dbobj) gives me the message "NULL"

Please help

Thanks
Jason

http 400 file: expecting a file upload

I have a problem trying to add a file to dropbox. The db log says 400 error code. What am I missing here?

This is my code:

    function save_to_dropbox() {

        // http://localhost:8888/mamaohla/test/save_to_dropbox/11109644961428152252_thumb.png
        // adding 11109644961428152252_thumb.png from root/photo/post folder
        // to dropbox root folder

        $thumb = $this->uri->segment(3);
        $path= FCPATH.'photo/post/';
        $filename = $path.$thumb;

        $dbpath = '';

        $params['key'] = $this->config->item('db_app_key');
        $params['secret'] = $this->config->item('db_app_secret');
        $params['access'] = array('oauth_token'=>urlencode($this->session->userdata('oauth_token')),
                                  'oauth_token_secret'=>urlencode($this->session->userdata('oauth_token_secret')));

        $this->load->library('dropbox', $params);

        $obj =$this->dropbox->account();

        // print_r($obj);

        // add thumb to dropbox
        $this->dropbox->add($dbpath, $filename);

    }

And this is dropbox error log

https://www.dropbox.com/s/c5jdlc9wwwyyil1/Screen%20Shot%202015-04-04%20at%208.03.31%20PM.png?dl=0

Upload File Issue

Hi

I seem to be having an issue trying to upload a file to Dropbox.
I have tested the connection and it all works fine; it returns the account details etc.
I have enabled debugging, but I don't actually seem to be getting any error messages in the logs, but the add() function is returning some data:

[Wed Jun 24 11:44:31 2015] [error] [client 87.127.109.10] POST /files/dropbox/Portal%20Archive/Telephone%20Directory-Sep14.pdf?file=https%3A%2F%2Fsandbox.arithmoportal.co.uk%2Fuploads%2FACC4%2F678aeb901b8fcc37375e53f52f802a72.pdf HTTP/1.1\r\nHost: api-content.dropbox.com\r\nConnection: close\r\nUser-Agent: CodeIgniter\r\nAccept-encoding: identity\r\nAuthorization: OAuth oauth_consumer_key="q78w7fnkpm99t2o", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1435146271", oauth_nonce="2eea3967328c2b2091baaf09b1243e72", oauth_version="1.0", oauth_token="el5hi7ku7d7dvspw", oauth_signature="a4h8qTlZmmov35MYzXmtyRHZSTI%3D"\r\n\r\n

[Wed Jun 24 11:44:31 2015] [error] [client 87.127.109.10] Array\n(\n [url] => https://api-content.dropbox.com/1/files/dropbox/Portal%20Archive/Telephone%20Directory-Sep14.pdf?file=https%3A%2F%2Fsandbox.arithmoportal.co.uk%2Fuploads%2FACC4%2F678aeb901b8fcc37375e53f52f802a72.pdf\n [content_type] => \n [http_code] => 0\n [header_size] => 0\n [request_size] => 0\n [filetime] => -1\n [ssl_verify_result] => 0\n [redirect_count] => 0\n [total_time] => 0.251891\n [namelookup_time] => 0.012708\n [connect_time] => 0.086594\n [pretransfer_time] => 0.251826\n [size_upload] => 0\n [size_download] => 0\n [speed_download] => 0\n [speed_upload] => 0\n [download_content_length] => -1\n [upload_content_length] => -1\n [starttransfer_time] => 0\n [redirect_time] => 0\n [certinfo] => Array\n (\n )\n\n [primary_ip] => 23.23.97.3\n [redirect_url] => \n)\n

Any advice appreciated.

Thanks

dropbox -> Dropbox

Not sure if this is the repo you use for the Spark but I am way too tired of fixing bugs to fix this one for you with a pull request, sorry.

$ git mv sparks/dropbox/1.1.3/libraries/dropbox.php sparks/dropbox/1.1.3/libraries/dropbox.php.tmp
$ git mv sparks/dropbox/1.1.3/libraries/dropbox.php.tmp sparks/dropbox/1.1.3/libraries/Dropbox.php

Lower-case will break case sensitive file systems.

Expecting A file Upload Error

$dbpath = 'backup';
$filepath = $save;
$uploaded = $this->dropbox->add($dbpath, $filepath);

Error Result
stdClass Object ( [error] => stdClass Object ( [file] => Expecting a file upload ) )

Store in db? Method missing in docs

Hi Jim,

Great to see you updating this library.

In your docs, you mention:

$oauth = $this->dropbox->get_access_token($this->session->userdata('token_secret')); $this->_store_in_db($oauth['oauth_token']); $this->_store_in_db($oauth['oauth_token_secret']);

Which, of course, gives me

Call to undefined method Dbox::_store_in_db()

Is this pseudocode, or have I skipped a section of the docs, or am I missing a library or a dependency or something?

My use for your library is to authenticate (once) as me, then when users upload files, then get copied to my dropbox and I get the sharing link back, so it's me authenticated, not them. Hence the db (database not dropbox) storage method.

Over at https://github.com/BenTheDesigner/Dropbox/tree/master/Dropbox/OAuth/Storage he's got a db encrypted storage method, and warns to never store tokens unencrypted.

Does your library have anything equivalent, or might it be possible to make a hybrid including some of his code? I'm slightly into "over my head" territory here so pointers would be appreciated!

logging

use Codeigniter log_message('debug', $header); instead error_log($header);

add parameters at /shares

public function shares($path, array $params = array(), $root=self::DEFAULT_ROOT)
    {
        $path = str_replace('%2F', '/', rawurlencode($path));
        $parstr = empty($params) ? '' : '?'.http_build_query($params);
        return $this->_response_request("/shares/{$root}/{$path}{$parstr}");
    }

undefined index : oauth_token

Hi Jim,

Upon test the drive exmaple/request dropbox I got these error:


Severity: Notice

Message: Undefined index: oauth_token

Filename: libraries/Dropbox.php

Line Number: 118

A PHP Error was encountered

Severity: Notice

Message: Undefined index: oauth_token_secret

Filename: libraries/Dropbox.php

Line Number: 120```

return value of _content_request is missing

private function _content_request($uri, $destination) does not return a value. so in case of $destination===false the response of _connect is lost. this function should return the return value of the _connect call. otherwise the case of $destination===false is useless.

Unable to upload

Everything seems to work in the example controller, and I get the user data no problem. However, when I try to upload something, I get the very nondescript error text, "Forbidden". My app only has access to one folder. I've tried the add() call a few different ways: full path to the app's folder, empty quotes, and just the file name. They all return the same thing, and without any real error text, I can't debug it. I know the error text is generated on dropbox's end, but I'm hoping you all know a way around this problem, or at least know what could cause it.

Outdated version

I duno why this is listed at the dropbox webpage but it's the secound project which is out of date and uses depricated SHA1 Hash instead of SHA256 and the newer API ans OAuth 2 version.

Please fix this!

Oh and don't write source as the following:

class blabla
{

}

This is false written OOP!

You have to write it like this:

class blabla {

public function blubblub(array $arr, $param) {

if ($param == true) {

//do this
} else {

/do smth.

}

}

This is the right OOP Structure for all brakets and no other own builds otherwise you don't have the rigth to call this OOP-Scripts!

Oh and don't try to use JSON in the newer version. I hate it because it's not for webpages so please try to use a simple REST API call

i am not able to upload file

i am not able to upload file into dropbox
and i am not getting any error just blank page is displaying...

i have written like this

$dbobj = $this->dropbox->add("folder_name","filename.pdf", $params, "sandbox");

please solve my problem any one.

No support for chunked_upload

Can you add a support for the chunked_upload feature of the Dropbox API?

The add function should also check that the file to be uploaded does not exceed the 150MB limit imposed by the API.

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.