share folder via Dropbox Ruby API

爱⌒轻易说出口 提交于 2019-12-21 03:00:06

问题


I want to share a dropbox folder via the Ruby API. Is it possible now or is there anyway?

Thanks


回答1:


There is always a way, but in this case it would require you to login programmatically via cURL and pass back and forth the data needed. I am trying to figure that out now myself.

[Edit]

Since there's still interest in this thread I'll post the basic instructions, it may have changed since I did this, but this is what was working 6 months ago.

1) You need to log in and remember your cookies.

The login URL is (was) https://www.dropbox.com/login

The data you need to post to the login page is below represented as a php array since that's what I used.

$loginData = array(
    't' => $loginToken,
    'login_email' => $_POST['input_from_email'],
    'login_password' => $_POST['input_from_email_password']
);

The login token is part of the login form and is to prevent XSS so you need to read it from there and include it in your form post or else it will fail.

Once you successfully login you have need to read in the HTML and headers using cURL for the url https://www.dropbox.com/home and parse the

preg_match("/.*TOKEN:(.*),.*/", $homeResponse, $homeResponseMatches); 

This pulls the XSS token for the next form which is the form that submits and creates the share. it is used by posting to the URL https://www.dropbox.com/share_ajax/new. and the data that needs to be posted is.

$createShareData = array(
    'emails' => $_POST['input_to_email'],
    'custom_message' => $_POST['input_message'],
    'folder_name' => $_POST['input_folder_name'],
    't' => $loggedInToken
);

'$loggedInToken' is the token you scraped from https://www.dropbox.com/home. This will create a new folder and share it with the emails in the 'emails' field which is a comma delimited list of email addresses.

Have fun.




回答2:


I've been scouring the API and the dev forum, and unforuntately I do not think it's possible (at least not in any straight forward manner).

http://forums.dropbox.com/topic.php?id=25478&replies=10

http://forums.dropbox.com/topic.php?id=22779



来源:https://stackoverflow.com/questions/5126401/share-folder-via-dropbox-ruby-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!