/** * 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; }
/** * Gets authorize URL and redirects to dropbox * * @return void HTTP redirect (to dropbox.com) */ public function setupDropboxPost() { $qs = ''; if (isset($_GET['edit'])) { $qs = '?edit'; } $secret = $this->getSecret(); try { getSession()->set('flowDropboxKey', $this->utility->encrypt($_POST['dropboxKey'], $secret)); getSession()->set('flowDropboxSecret', $this->utility->encrypt($_POST['dropboxSecret'], $secret)); getSession()->set('flowDropboxFolder', $_POST['dropboxFolder']); $callback = urlencode(sprintf('%s://%s%s%s', $this->utility->getProtocol(false), getenv('HTTP_HOST'), '/setup/dropbox/callback', $qs)); $oauth = new Dropbox_OAuth_PHP($_POST['dropboxKey'], $_POST['dropboxSecret']); getSession()->set('dropboxToken', $oauth->getRequestToken()); $url = $oauth->getAuthorizeUrl($callback); $this->route->redirect($url, null, true); } catch (Dropbox_Exception $e) { getLogger()->crit('An error occured getting the Dropbox authorize url.', $e); $this->route->run('/error/500', EpiRoute::httpGet); } }
include 'Dropbox/autoload.php'; require_once 'Dropbox.php'; $consumerKey = '4345435636dffr2455'; $consumerSecret = '442342342343254asa'; session_start(); $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();
<?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