1

我想创建 php 页面以将文件上传到我的保管箱。我从我的保管箱帐户中获得了密钥和密钥。

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

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

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

2 回答 2

0

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

$client = new Dropbox\Client($accessToken);
$info = $client->getAccountInfo();
echo $info["uid"];
于 2013-12-08T05:18:02.027 回答
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 应用程序中授权之前运行

于 2013-12-28T11:14:37.167 回答