public function index() { $session = $this->request->session(); if ($this->request->is('post')) { /* TODO: * Доделать авторизацию dropbox; */ $app = $this->request->data('Appname'); $key = $this->request->data('Key'); $secret = $this->request->data('Secret'); if ($app !== null && $key !== null && $secret !== null) { $dbx_cfg = ['app' => $app, 'key' => $key, 'sec' => $secret]; $session->write('CakeD.dropbox.auth_data', $dbx_cfg); } else { $dbx_cfg = $session->consume('CakeD.dropbox.auth_data'); } $appInfo = new dbx\AppInfo($dbx_cfg['key'], $dbx_cfg['sec']); $webAuth = new dbx\WebAuthNoRedirect($appInfo, $dbx_cfg['app']); $authorizeUrl = $webAuth->start(); $this->set('auth_url', $authorizeUrl); if ($this->request->data('AuthCode')) { list($accessToken, $dropboxUserId) = $webAuth->finish($this->request->data('AuthCode')); $this->set('token', $accessToken); } } }
<?php use RingCentral\SDK\Http\HttpException; use RingCentral\http\Response; use RingCentral\SDK; use Dropbox as dbx; // require_once "dropbox-sdk/Dropbox/autoload.php"; // ---------------------- Send SMS -------------------- echo "\n"; echo "------------Download Call Recordings to dropbox ----------------"; echo "\n"; try { // Dropbox Authentication $appInfo = dbx\AppInfo::loadFromJsonFile("app/config.json"); $webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0"); $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"; $authCode = \trim(\readline("Enter the authorization code here: ")); list($accessToken, $dropboxUserId) = $webAuth->finish($authCode); print "Access Token: " . $accessToken . "\n"; $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0"); // RC call logs $callRecordings = $platform->get('/account/~/extension/~/call-log', array('type' => 'Voice', 'withRecording' => 'True'))->json()->records; $timePerRecording = 6; foreach ($callRecordings as $i => $callRecording) { if (property_exists($callRecording, 'recording')) { $id = $callRecording->recording->id; print "Downloading Call Log Record {$id}" . PHP_EOL; $uri = $callRecording->recording->contentUri;
header('Location: ' . BASE_URL . "error-403"); exit; } include_once ROOT_PATH . '/plugins/mysqldump-php-1.4.1/src/Ifsnop/Mysqldump/Mysqldump.php'; $appInfoFile = ROOT_PATH . "config/dropbox.app"; # Include the Dropbox SDK libraries require_once ROOT_PATH . "plugins/dropbox-sdk/lib/Dropbox/autoload.php"; use Dropbox as dbx; try { $terms = TermFetcher::retrieveAll(); $accessTokenDatabase = DropboxFetcher::retrieveAccessToken(DropboxCon::SERVICE_APP_DATABASE_BACKUP)[DropboxFetcher::DB_COLUMN_ACCESS_TOKEN]; $accessTokenExcel = DropboxFetcher::retrieveAccessToken(DropboxCon::SERVICE_APP_EXCEL_BACKUP)[DropboxFetcher::DB_COLUMN_ACCESS_TOKEN]; // var_dump($accessTokenDatabase); $appInfo = dbx\AppInfo::loadFromJsonFile($appInfoFile); $clientIdentifier = "sass-app/1.0"; $webAuth = new dbx\WebAuthNoRedirect($appInfo, $clientIdentifier, "en"); if ($accessTokenDatabase !== NULL) { try { $dbxClientDB = new dbx\Client($accessTokenDatabase, "PHP-Example/1.0"); $accountInfoDatabase = $dbxClientDB->getAccountInfo(); } catch (Exception $e) { $errors[] = "Could not access Dropbox account database. Maybe user has revoked access?"; } } if ($accessTokenExcel !== NULL) { try { $dbxClientExcel = new dbx\Client($accessTokenExcel, "PHP-Example/1.0"); $accountInfoExcel = $dbxClientExcel->getAccountInfo(); } catch (Exception $e) { $errors[] = "Could not access Dropbox account excel. Maybe user has revoked access?"; }
<?php require_once "vendor/autoload.php"; use Dropbox; $appInfo = Dropbox\AppInfo::loadFromJsonFile("config.json"); $webAuth = new Dropbox\WebAuthNoRedirect($appInfo, "ArcherSys/1.0"); $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"; $authCode = \trim(\readline("Enter the authorization code here: ")); ?>
<html> <head> <meta charset="UTF-8"> <title>Cloud Storage Pool (CSP) - Dropbox Autorisierung</title> </head> <body> <h1>Cloud Storage Pool (CSP) - Dropbox Autorisierung</h1> <?php require_once "config.inc.php"; require_once "api/Dropbox/autoload.php"; use Dropbox as dbx; $appInfo = dbx\AppInfo::loadFromJson($config_dropbox_appinfo); $webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0"); if (isset($_POST['auth_code'])) { list($accessToken, $dropboxUserId) = $webAuth->finish($_POST['auth_code']); echo "Autorisierung der App ist erfolgt. <br>"; echo "Bitte tragen Sie den unten stehenden Access Token in die CSP Konfigruration ein. <br>"; echo "Access Token: " . $accessToken . "\n"; } else { $authorizeUrl = $webAuth->start(); if ($authorizeUrl) { echo "1. Klick auf <a href='" . $authorizeUrl . "' target='_blank'>Link</a>, Autorisierung der App und Kopieren des Codes<br />"; echo "2. Den Code hier einfügen und absenden:<br /><br />"; echo "<form method='post'>"; echo "\t<input type='text' name='auth_code''>"; echo "\t<input type='submit' value='Code absenden' class='button' />"; echo "</form>"; echo "3. Den anschließend angezeigten Access Token in die CSP Konfigruration einfügen.<br /><br />"; } else { echo "Keine gültige AuthURL erhelten. Bitte Key und Secret prüfen."; }
public function getAuthUrl() { $webAuth = new \Dropbox\WebAuthNoRedirect($this->appInfo, "PHP-Example/1.0"); return $webAuth->start(); }