/** * Initialize open authentication */ protected function initOAuth() { $this->oAuth = new Dropbox_OAuth_PHP($this->configuration->getDropboxConsumerKey(), $this->configuration->getDropboxConsumerSecret()); $oAuthTokens = $this->registry->get('tx_dlDropbox', 'oauth_tokens'); if (is_array($oAuthTokens) && array_key_exists('token_secret', $oAuthTokens) && $oAuthTokens['token_secret']) { $this->oAuth->setToken($oAuthTokens); $this->isAuthenticated = TRUE; } }
public function __construct($parent, $config = null, $params = null) { $this->config = !is_null($config) ? $config : getConfig()->get(); $this->directoryMask = 'Y_m_F'; $utilityObj = new Utility(); $oauth = new Dropbox_OAuth_PHP($utilityObj->decrypt($this->config->credentials->dropboxKey), $utilityObj->decrypt($this->config->credentials->dropboxSecret)); $oauth->setToken(array('token' => $utilityObj->decrypt($this->config->credentials->dropboxToken), 'token_secret' => $utilityObj->decrypt($this->config->credentials->dropboxTokenSecret))); $this->dropbox = new Dropbox_API($oauth, Dropbox_API::ROOT_SANDBOX); $this->dropboxFolder = $this->config->dropbox->dropboxFolder; $this->parent = $parent; }
/** * Handles callback from Dropbox oauth flow * * @return void HTTP redirect (to dropbox.com) */ public function setupDropboxCallback() { $secret = $this->getSecret(); try { $dropboxToken = getSession()->get('dropboxToken'); $dropboxKey = $this->utility->decrypt(getSession()->get('flowDropboxKey'), $secret); $dropboxSecret = $this->utility->decrypt(getSession()->get('flowDropboxSecret'), $secret); $oauth = new Dropbox_OAuth_PHP($dropboxKey, $dropboxSecret); $oauth->setToken($dropboxToken); $accessToken = $oauth->getAccessToken(); getSession()->set('dropboxFolder', getSession()->get('flowDropboxFolder')); getSession()->set('dropboxKey', getSession()->get('flowDropboxKey')); getSession()->set('dropboxSecret', getSession()->get('flowDropboxSecret')); getSession()->set('dropboxToken', $this->utility->encrypt($accessToken['token'], $secret)); getSession()->set('dropboxTokenSecret', $this->utility->encrypt($accessToken['token_secret'], $secret)); $qs = ''; if (isset($_GET['edit'])) { $qs = '?edit'; } $this->route->redirect(sprintf('%s%s', '/setup/3', $qs)); } catch (Dropbox_Exception $e) { getLogger()->crit(sprintf('An error occured getting the Dropbox authorize url. Message: %s', $e->getMessage())); $this->route->run('/error/500'); } }
$oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret); $dropbox = new Dropbox_API($oauth); $account = $dropbox->getAccountInfo(); echo $account; $tokens = $dropbox->getToken('*****@*****.**', 'wowpassword'); $_SESSION["oauth_tokens"]=$tokens; $oauth->setToken($oauth_tokens); $metaData = $dropbox->metaData(); if ($file_type = $data->mime_type !="jpeg/image") { break; } foreach ($metaData['body']->contents as $data) { if ($file_type = $data->mime_type !="jpeg/image") { break; } $file_size = $data->size;
<?php $consumerKey = 'key'; // key $consumerSecret = 'sercret'; // sercret include 'vendor/dropbox-php/dropbox-php/src/Dropbox/autoload.php'; $oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret); $dropbox = new Dropbox_API($oauth); // auth $tokens = $dropbox->getToken('email', 'pass'); $oauth->setToken($tokens); $h = fopen('/PATH/browserling.jpg', 'r'); // upload file $dropbox->putFile('browserling.jpg', $h); // put file