Ejemplo n.º 1
0
echo "<pre>";
echo "<b>Account:</b>\r\n";
print_r($dropbox->GetAccountInfo());
$files = $dropbox->GetFiles("", false);
if (empty($files)) {
    $dropbox->UploadFile("leonidas.jpg");
    $files = $dropbox->GetFiles("", false);
}
echo "\r\n\r\n<b>Files:</b>\r\n";
print_r(array_keys($files));
if (!empty($files)) {
    $file = reset($files);
    $test_file = "test_download_" . basename($file->path);
    echo "<img src='" . $dropbox->GetLink($file, false) . "'/></br>";
    echo "\r\n\r\n<b>Meta data of <a href='" . $dropbox->GetLink($file) . "'>{$file->path}</a>:</b>\r\n";
    print_r($dropbox->GetMetadata($file->path));
    echo "{$test_file}</br>";
    echo "\r\n\r\n<b>Downloading {$file->path}:</b>\r\n";
    print_r($dropbox->DownloadFile($file, $test_file));
    echo "\r\n\r\n<b>Uploading {$test_file}:</b>\r\n";
    print_r($dropbox->UploadFile($test_file));
    echo "\r\n done!";
    echo "\r\n\r\n<b>Revisions of {$test_file}:</b>\r\n";
    print_r($dropbox->GetRevisions($test_file));
}
echo "\r\n\r\n<b>Searching for JPG files:</b>\r\n";
$jpg_files = $dropbox->Search("/", ".jpg", 5);
if (empty($jpg_files)) {
    echo "Nothing found.";
} else {
    print_r($jpg_files);
Ejemplo n.º 2
0
Archivo: sync.php Proyecto: rich13/info
// checks if access token is required
if(!$dropbox->IsAuthorized()){

	// redirect user to dropbox auth page
	$return_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']."?auth_callback=1";
	$auth_url = $dropbox->BuildAuthorizeUrl($return_url);
	$request_token = $dropbox->GetRequestToken();
	store_token($request_token, $request_token['t']);
	die("Authentication required. <a href='$auth_url'>Click here.</a>");
}

# - - - - - - - - - - - - -
# Get overall directory metadata

$db_meta = $dropbox->GetMetadata($sync_directory); // need to look into current subdir?
if(!$db_meta){ die("Nothing coming back from Dropbox..."); }

# - - - - - - - - - - - - -
# get the hash and store it

$hash = $db_meta->hash;
$dropbox_sync_hash = "content/remote/.dropbox_sync_hash";

if(!file_exists($dropbox_sync_hash)){
	file_put_contents($dropbox_sync_hash, $hash);
	$our_hash = -1;	
} else {
	$our_hash = file_get_contents($dropbox_sync_hash);
}