/** * Prepares the environment before running a test. */ protected function setUp() { parent::setUp(); $this->dropbox = new Dropbox(APPLICATION_KEY, APPLICATION_SECRET); $this->dropbox->setOAuthToken(TOKEN); $this->dropbox->setOAuthTokenSecret(TOKEN_SECRET); }
throw new Exception('Cannot rename uploaded file!'); // Upload //$uploader = new Dropbox('*****@*****.**','initpass'); $dropbox = new Dropbox('0b6mkq8ervg1zd5', 'p9tgw4dpb57e0eh'); $uploader = $dropbox->token('*****@*****.**', 'initpass'); $dropbox->setOAuthToken($uploader['token']); $dropbox->setOAuthTokenSecret($uploader['secret']); $response = $dropbox->filesPost('resumes', $tmpFile); // output response if(!$response['result'] == "winner!") { throw new Exception('Error on the upload to Dropbox!'); }
<?php // require require_once 'config.php'; require_once '../dropbox.php'; // create instance $dropbox = new Dropbox(APPLICATION_KEY, APPLICATION_SECRET); $dropbox->setOAuthToken(TOKEN); $dropbox->setOAuthTokenSecret(TOKEN_SECRET); // oAuth dance //$response = $dropbox->oAuthRequestToken(); //if(!isset($_GET['authorize'])) $dropbox->oAuthAuthorize($response['oauth_token'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] .'?authorize=true'); //else $response = $dropbox->oAuthAccessToken($_GET['oauth_token']); //$response = $dropbox->token(EMAIL, PASSWORD); //$response = $dropbox->account(time() . '*****@*****.**', PASSWORD, 'Tijs', 'Verkoyen'); //$response = $dropbox->accountInfo(); //$response = $dropbox->filesGet(BASE_PATH .'hàh@, $.txt'); //$response = $dropbox->filesPost(BASE_PATH, realpath('../dropbox.php')); //$response = $dropbox->filesPost(BASE_PATH .'with spaces', realpath('../dropbox.php')); //$response = $dropbox->filesPost(BASE_PATH .'met spaties/', realpath('/Users/tijs/Projects/dropbox/tests/with spaces.txt')); //$response = $dropbox->metadata(BASE_PATH .'met spaties'); //$response = $dropbox->thumbnails(BASE_PATH .'image.png'); //$response = $dropbox->fileopsCopy(BASE_PATH . 'image.png', BASE_PATH . 'copy_' . time()); //$response = $dropbox->fileopsCreateFolder(BASE_PATH .'created_'. time()); //$response = $dropbox->fileopsDelete(BASE_PATH .'will_be_deleted'); //$response = $dropbox->fileopsMove(BASE_PATH .'will_be_moved', BASE_PATH .'moved_'. time()); // output (Spoon::dump()) ob_start(); var_dump($response); $output = ob_get_clean(); // cleanup the output
function repositoryDropbox($args) { extract($args); if (isset($consumer_secret) && !empty($consumer_secret)) { require_once APP_ROOT . '/lib/dropbox.oauth.php'; $dropbox = new Dropbox($consumer_key, $consumer_secret); $dropbox->setOAuthToken($oauth_token); $dropbox->setOAuthTokenSecret($oauth_token_secret); try { $dropbox->accountinfo(); return array('status' => 'success'); } catch (Exception $e) { return array('status' => 'error', 'errorMsg' => $e->getMessage()); } } return array('status' => 'error', 'errorMsg' => 'Consumer Secret not available'); }