1

I want to create php page for upload file into my dropbox. I have got key and secret key from my dropbox account.

From here I got coding for dropbox but I did not get user id. How can I get user id of dropbox.

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

list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
print "Access Token: " . $accessToken . "\n";
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
Maulik Parmar
  • 857
  • 10
  • 15

2 Answers2

0

I assume you're using the standard PHP Dropbox SDK

$client = new Dropbox\Client($accessToken);
$info = $client->getAccountInfo();
echo $info["uid"];
Andy Jones
  • 6,205
  • 4
  • 31
  • 47
  • Thanks Andy Jones but I have not $accessToken. How to get it? Php did not show me any error after execute following code and exit from below code. and also I am not getting $authorizeUrl. Can you give me code to upload file using the standard PHP Dropbox SDK. $authorizeUrl = $webAuth->start(); – Maulik Parmar Dec 08 '13 at 09:02
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>";
}

to run before you have to authorized in dropbox apps

Hiren Raiyani
  • 754
  • 2
  • 12
  • 28