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;
public function getAuthUrl() { $webAuth = new \Dropbox\WebAuthNoRedirect($this->appInfo, "PHP-Example/1.0"); return $webAuth->start(); }