如何获取Dropbox用户ID?

时间:2013-12-08 05:10:21

标签: php dropbox-php

我想创建上传文件的php页面到我的Dropbox。 我的Dropbox帐户中有密钥和密钥。

从这里我得到了Dropbox的编码,但我没有获得用户ID。 如何获取dropbox的用户ID。

https://www.dropbox.com/developers/core/start/php

list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
print "Access Token: " . $accessToken . "\n";

2 个答案:

答案 0 :(得分:0)

我假设您使用的是标准的PHP Dropbox SDK

$client = new Dropbox\Client($accessToken);
$info = $client->getAccountInfo();
echo $info["uid"];

答案 1 :(得分:0)

<?php
error_reporting(E_ALL);
require_once("DropboxClient.php");

// you have to create an app at https://www.dropbox.com/developers/apps and enter   details below:
$dropbox = new DropboxClient(array(
'app_key' => "", 
'app_secret' => "",
    'app_full_access' => true,
),'en');

handle_dropbox_auth($dropbox); // see below

// if there is no upload, show the form
if(empty($_FILES['the_upload'])) {
?>
<form enctype="multipart/form-data" method="POST" action="">
<p>
<label for="file">Upload File</label>
<input type="file" name="the_upload" />
</p>
<p><input type="submit" name="submit-btn" value="Upload!"></p>
</form>
<?php } else { 

    $upload_name = $_FILES["the_upload"]["name"];
echo "<pre>";
echo "\r\n\r\n<b>Uploading $upload_name:</b>\r\n";
$meta = $dropbox->UploadFile($_FILES["the_upload"]["tmp_name"], $upload_name);
print_r($meta);
echo "\r\n done!";
echo "</pre>";
}

在您必须在Dropbox应用程序中授权之前运行