我尝试使用cURL和PHP以用户身份登录Dropbox。
$ch = curl_init();
$data = array(
't'=>'hxdlvCcN7SKKcfKCvpEO8-s2',
'lhs_type'=>'anywhere',
'login_email'=>'myemail@mail.com',
'password'=>'mypass',
'login_submit'=>1,
'remember_me'=>'on',
'login_submit_dummy'=>'Sign in'
);
// set cURL options and execute
curl_setopt($ch, CURLOPT_URL, "https://www.dropbox.com/login?lhs_type=anywhere");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));
$request_token_response = curl_exec($ch);
var_dump($request_token_response );
我用这个文字得到403页:
It seems you tried to do something we can't verify. Did you log into a different Dropbox account in a different window? Try clicking here to go back to the page you came from, or just go home.
我做错了什么?
答案 0 :(得分:0)
这是可能的,并且有一个当前的课程可以让它变得容易。 https://github.com/jakajancar/DropboxUploader/
就像
一样简单require 'DropboxUploader.php';
$uploader = new DropboxUploader('email@address.com', 'password');
如果您已登录,$uploader->loggedin
将会返回。
答案 1 :(得分:0)
我想你会发现''值只能使用一次。每次登录时都需要换一个新的。
如果你查看另一篇文章中建议的类,你会发现它就是这样。