public function dropbox() { //return Input::file('uploadfile'); //return $uploadfile = Input::file('uploadfile'); //use \Dropbox as dbx; $appInfo = \Dropbox\AppInfo::loadFromJsonFile("app_info.json"); $webAuth = new \Dropbox\WebAuthNoRedirect($appInfo, "PHP-Example/1.0"); $authorizeUrl = $webAuth->start(); $accessToken = "LUu8h-uvauAAAAAAAAAAHbDw-bulVL7u8BoRAJtedc0-eCDY-Xj4Qxf1iGucUN7j"; $dbxClient = new \Dropbox\Client($accessToken, "PHP-Example/1.0"); $accountInfo = $dbxClient->getAccountInfo(); // $dbxClient->getAccessToken(); //return $dbxClient->_getMetadata("/participant/Fl0dsItC_Airtel.png"); $host = $dbxClient->getHost(); return $this->fetchUrl("/participant/Fl0dsItC_Airtel.png"); //$appendFilePath = $dbxClient->appendFilePath(); //print_r($appendFilePath); /*echo "1. Go to: " . $authorizeUrl . "\n"; echo "2. Click \"Allow\" (you might have to log in first).\n"; echo "3. Copy the authorization code.\n"; $authCode = \trim(\readline("Enter the authorization code here: ")); list($accessToken, $dropboxUserId) = $webAuth->finish($authCode); print "Access Token: " . $accessToken . "\n"; */ /*$f = fopen(url()."/public/assets/upload/contest_theme_photo/Fl0dsItC_Airtel.png", "rb"); $result = $dbxClient->uploadFile("/participant/Fl0dsItC_Airtel.png", \Dropbox\WriteMode::add(), $f); fclose($f);*/ $f = fopen("Fl0dsItC_Airtel.png", "w+b"); $fileMetadata = $dbxClient->getFile("/participant/Fl0dsItC_Airtel.png", $f); //return $dbxClient->getMetadata("/participant/Fl0dsItC_Airtel.png"); fclose($f); //return View::make('dropbox/dropbox'); }
* $mode string Mode for configuring this destination. Values: add, edit, save * $destination_settings array Array of this destination's configuration settings. Key => value pairs. * * Globally editable variables: * $pb_hide_test bool Whether or not to hide the "Test" button. Modifiable. * $pb_hide_save bool Whether or not to hide the "Save" button. Modifiable. * */ global $pb_hide_test, $pb_hide_save; $pb_hide_test = true; // Always hiding test button for Dropbox. $pb_hide_save = true; $show_config_form = false; if ('add' == $mode) { // ADD mode. $webAuth = new \Dropbox\WebAuthNoRedirect(pb_backupbuddy_destination_dropbox2::$appInfo, 'BackupBuddy v' . pb_backupbuddy::settings('version'), 'en'); $bad_auth_code = false; if ('' != pb_backupbuddy::_POST('dropbox_authorization_code')) { // Authorization code entered. Try it out before showing form or not. $pb_hide_save = false; $authCode = trim(pb_backupbuddy::_POST('dropbox_authorization_code')); try { list($accessToken, $dropboxUserId) = $webAuth->finish($authCode); } catch (\Exception $e) { pb_backupbuddy::alert('<b>Verify you authorized BackupBuddy access in Dropbox and copied the Dropbox authorization code exactly in the BackupBuddy field.</b><br><br>Error details: ' . $e->getMessage(), true); // '<br><br>' . pb_backupbuddy::$ui->button( pb_backupbuddy::page_url(), '← go back & retry' ) $bad_auth_code = true; $pb_hide_save = true; } if (false === $bad_auth_code) { $dropboxClient = new \Dropbox\Client($accessToken, 'BackupBuddy v' . pb_backupbuddy::settings('version'));
// Make sure the Dropbox SDK has been installed if (!@is_dir(dirname(__DIR__) . '/vendor/dropbox/dropbox-sdk')) { throw new \Exception('Please install the Dropbox SDK by running \'composer install\' in the edropub root directory.', 2); } // Require common settings require_once dirname(__DIR__) . '/config/common.php'; // Activate error reporting require_once dirname(__DIR__) . '/vendor/dropbox/dropbox-sdk/lib/Dropbox/strict.php'; // Include the Dropbox autoloader in case the composer autoloader is not already active if (!class_exists('\\Dropbox\\AppInfo')) { echo "auto\n\n"; require_once dirname(__DIR__) . '/vendor/dropbox/dropbox-sdk/lib/Dropbox/autoload.php'; } list($appInfoJson, $appInfo) = \Dropbox\AppInfo::loadFromJsonFileWithRaw(dirname(__DIR__) . '/config/config.json'); // This is a command-line tool (as opposed to a web app), so we can't supply a redirect URI. $webAuth = new \Dropbox\WebAuthNoRedirect($appInfo, "examples-authorize", "en"); $authorizeUrl = $webAuth->start(); echo "1. Go to: {$authorizeUrl}\n"; echo "2. Click \"Allow\" (you might have to log in first).\n"; echo "3. Copy the authorization code.\n"; echo "Enter the authorization code here: "; $authCode = \trim(\fgets(STDIN)); list($accessToken, $userId) = $webAuth->finish($authCode); echo "Authorization complete.\n"; echo "- User ID: {$userId}\n"; echo "- Access Token: {$accessToken}\n"; $authArr = array('access_token' => $accessToken, 'editorially_prefix' => '/Apps/Editorially', 'leadpub_api_key' => '<YOUR_ACCOUNT_API_KEY>', 'leadpub_prefix' => '/<YOUR_BOOKS_SLUG>', 'leanpub_trigger' => 'preview'); if (array_key_exists('host', $appInfoJson)) { $authArr['host'] = $appInfoJson['host']; } $argAuthFileOutput = dirname(__DIR__) . '/config/access.json';