コード例 #1
0
ファイル: dropbox.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Initializes the dropbox connection
  *
  * @param   array   $params  Any connection params needed
  * @return  \League\Flysystem\Dropbox\DropboxAdapter
  **/
 public static function init($params = [])
 {
     // Get the params
     $pparams = Plugin::params('filesystem', 'dropbox');
     if (isset($params['app_token'])) {
         $accessToken = $params['app_token'];
     } else {
         $info = ['key' => isset($params['app_key']) ? $params['app_key'] : $pparams->get('app_key'), 'secret' => isset($params['app_secret']) ? $params['app_secret'] : $pparams->get('app_secret')];
         \Session::set('dropbox.app_key', $info['key']);
         \Session::set('dropbox.app_secret', $info['secret']);
         \Session::set('dropbox.connection_to_set_up', Request::getVar('connection', 0));
         $appInfo = \Dropbox\AppInfo::loadFromJson($info);
         $clientIdentifier = 'hubzero-cms/2.0';
         $redirectUri = trim(Request::root(), '/') . '/developer/callback/dropboxAuthorize';
         $csrfTokenStore = new \Dropbox\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
         $oauth = new \Dropbox\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore);
         // Redirect to dropbox
         // We hide the return url in the state field...that's not exactly what
         // it was intended for, but it does the trick
         $return = Request::getVar('return') ? Request::getVar('return') : Request::current(true);
         $return = base64_encode($return);
         App::redirect($oauth->start($return));
     }
     $app_secret = isset($params['app_secret']) ? $params['app_secret'] : $pparams->get('app_secret');
     // Create the client
     $client = new \Dropbox\Client($accessToken, $app_secret);
     // Return the adapter
     return new \League\Flysystem\Dropbox\DropboxAdapter($client, isset($params['subdir']) ? $params['subdir'] : null);
 }
コード例 #2
0
ファイル: callback.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Processes the dropbox callback from oauth authorize requests
  *
  * @return    void
  **/
 public function dropboxAuthorizeTask()
 {
     $pparams = \Plugin::params('filesystem', 'dropbox');
     $app_key = \Session::get('dropbox.app_key', false);
     $app_secret = \Session::get('dropbox.app_secret', false);
     $new_connection = Session::get('dropbox.connection_to_set_up', false);
     $info = ['key' => isset($app_key) ? $app_key : $pparams->get('app_key'), 'secret' => isset($app_secret) ? $app_secret : $pparams->get('app_secret')];
     $appInfo = \Dropbox\AppInfo::loadFromJson($info);
     $clientIdentifier = 'hubzero-cms/2.0';
     $redirectUri = trim(\Request::root(), '/') . '/developer/callback/dropboxAuthorize';
     $csrfTokenStore = new \Dropbox\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
     $oauth = new \Dropbox\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore);
     \Session::set('dropbox.app_key', false);
     \Session::set('dropbox.app_secret', false);
     list($accessToken, $userId, $urlState) = $oauth->finish($_GET);
     //if this is a new connection, we can save the token on the server to ensure that it is used next time
     if ($new_connection) {
         require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'models' . DS . 'orm' . DS . 'connection.php';
         $connection = \Components\Projects\Models\Orm\Connection::oneOrFail($new_connection);
         $connection_params = json_decode($connection->get('params'));
         $connection_params->app_token = $accessToken;
         $connection->set('params', json_encode($connection_params));
         $connection->save();
     }
     // Redirect to the local endpoint
     App::redirect(base64_decode($urlState));
 }
コード例 #3
0
 /**
  * this will transfer the dbBackup zip to dropbox(LEAD-140)
  */
 public function transferZip()
 {
     $root_dir = dirname(__DIR__);
     $backUpFolderPath = $root_dir . '/api/dbBackUp';
     $host = gethostname();
     $db_name = 'mydb';
     /*dropbox settings starts here*/
     $dropbox_config = array('key' => 'xxxxxxxx', 'secret' => 'xxxxxxxxx');
     $appInfo = dbx\AppInfo::loadFromJson($dropbox_config);
     $webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
     $accessToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
     $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
     /*dropbox settings ends here*/
     $current_date = date('Y-m-d');
     $backUpFileName = $current_date . '_' . $db_name . '.sql.zip';
     $fullBackUpPath = $backUpFolderPath . '/' . $backUpFileName;
     if (file_exists($backUpFolderPath)) {
         $files = scandir($backUpFolderPath);
         //retrieve all the files
         foreach ($files as $file) {
             if ($file == $backUpFileName) {
                 // file matches with the db back up file created today
                 /* transfer the file to dropbox*/
                 $f = fopen($fullBackUpPath, "rb");
                 $dbxClient->uploadFileChunked("/{$backUpFileName}", dbx\WriteMode::add(), $f);
                 fclose($f);
                 echo 'Upload Completed';
             }
         }
     }
 }
コード例 #4
0
 public function __construct()
 {
     $this->appInfo = \Dropbox\AppInfo::loadFromJson(['key' => Yii::$app->params['dropbox_key'], 'secret' => Yii::$app->params['dropbox_secret']]);
     if ($dropboxUserAccess = DropboxUserAccess::findByAttributes(['user_id' => Yii::$app->user->model->id])) {
         $this->client = new \Dropbox\Client($dropboxUserAccess->access_token, "PHP-Example/1.0");
         $this->dropboxUserAccess = $dropboxUserAccess;
     }
 }
コード例 #5
0
ファイル: SignPresenter.php プロジェクト: xxdavid/texist
 private function getDropboxWebAuth()
 {
     $appInfo = \Dropbox\AppInfo::loadFromJson(["key" => $this->storage->get('appKey'), 'secret' => $this->storage->get('appSecret')]);
     $this->absoluteUrls = true;
     $this->session->start();
     $webAuth = new \Dropbox\WebAuth($appInfo, 'Texist', $this->link('Sign:in', ['step' => 2]), new ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token'));
     $this->absoluteUrls = false;
     return $webAuth;
 }
コード例 #6
0
 private static function getDropBoxAuth($config)
 {
     $data = array('key' => $config['DROPBOX_KEY'], 'secret' => $config['DROPBOX_SECRET']);
     $appInfo = dbx\AppInfo::loadFromJson($data);
     $clientIdentifier = "my-app/1.0";
     $redirectUri = $config['DROPBOX_REDIRECT_URI'];
     $csrfTokenStore = new dbx\ArrayEntryStore($_ENV, 'dropbox-auth-csrf-token');
     return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore);
 }
コード例 #7
0
 /**
  * __construct
  * 
  * Initialisierung der allgemenen Klassenvariablen
  *
  * @param string		$id   		Eindeutige ID des virtuellen Datenspeichers
  * @param string		$name   	Eindeutiger Bezeichnung des virtuellen Datenspeichers
  * @param string		$ext_root   Root Ordner der Instanz innerhalb des externen Datenspeichers
  * @param string		$token   	Authorisierungs Token zur Verbindung mit dem externen Datnespeicher
  * @param string		$crypto_key Passphrase zur Verschlüsselung der Daten innderhalb des externen Datenspeichers
  * @param Array		$appinfo	Dropbox Appinfo Array("key","secret")
  */
 function __construct($id, $name, $ext_root, $token, $crypto_key, $appinfo)
 {
     parent::__construct($id, $name, $ext_root, $token, $crypto_key);
     $this->type = "DRPBO";
     //Dropboxzugriff initialisieren
     $this->appInfo = \Dropbox\AppInfo::loadFromJson($appinfo);
     $this->webAuth = new \Dropbox\WebAuthNoRedirect($this->appInfo, "PHP-Example/1.0");
     $this->dbxClient = new \Dropbox\Client($this->token, "PHP-Example/1.0");
 }
コード例 #8
0
 /**
  * @return \Dropbox\Config
  */
 public function getAuth()
 {
     if (!$this->auth) {
         $app_info = new stdClass();
         $app_info->key = $this->getAdminConfigObject()->getAppKey();
         $app_info->secret = $this->getAdminConfigObject()->getAppSecret();
         $app_info->access_type = "AppFolder";
         $app_info->root = 'auto';
         $app_info = ilJsonUtil::encode($app_info);
         $info = \Dropbox\AppInfo::loadFromJson(json_decode($app_info, true));
         $client_identifier = $this->getAdminConfigObject()->getAppName();
         $token_store = new Dropbox\ArrayEntryStore($_SESSION, 'dropbox-auth-token');
         $redirect_uri = ILIAS_HTTP_PATH . '/Customizing/global/plugins/Modules/Cloud/CloudHook/Dropbox/redirect.php';
         $this->auth = new Dropbox\WebAuth($info, $client_identifier, $redirect_uri, $token_store);
     }
     return $this->auth;
 }
コード例 #9
0
ファイル: dropbox_lib.php プロジェクト: troywmz/JustWriting
 function getAppConfig()
 {
     $key = $this->CI->blog_config['dropbox']['key'];
     $secret = $this->CI->blog_config['dropbox']['secret'];
     if (empty($key) || empty($secret)) {
         throw new Exception("Must set dropbox key and secret");
     }
     $appInfo = array('key' => $key, 'secret' => $secret);
     try {
         $appInfo = dbx\AppInfo::loadFromJson($appInfo);
     } catch (dbx\AppInfoLoadException $ex) {
         throw new Exception("Unable to load \"{$appInfo}\": " . $ex->getMessage());
     }
     $clientIdentifier = "justwriting";
     $userLocale = null;
     return array($appInfo, $clientIdentifier, $userLocale);
 }
 protected function legacy()
 {
     echo "dropbox test";
     /** @var \Shockwavedesign\Mail\Dropbox\Model\Dropbox\User $dropboxUser */
     $dropboxUser = $this->scopeConfig->getDropboxUser();
     $key = $this->config->getValue('system/smtp/dropbox_key', ScopeInterface::SCOPE_STORE);
     $secret = $this->config->getValue('system/smtp/dropbox_secret', ScopeInterface::SCOPE_STORE);
     $accessToken = $dropboxUser->getAccessToken();
     $path = $this->config->getValue('system/smtp/dropbox_host_temp_folder_path', ScopeInterface::SCOPE_STORE);
     $appInfo = dbx\AppInfo::loadFromJson(array('key' => $key, 'secret' => $secret));
     //$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 = "WDUOKE3OsNIAAAAAAAATNEuROlA8b_uXFy0zJ6Rb_XM";
     //list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
     //print "DropboxUserId: " . $dropboxUserId . "Access Token: " . $accessToken . "\n";
     $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
     $accountInfo = $dbxClient->getAccountInfo();
     print_r($accountInfo);
     /*
     $f = fopen($path . "test.txt", "rb");
     $result = $dbxClient->uploadFile("/test.txt", dbx\WriteMode::add(), $f);
     fclose($f);
     print_r($result);
     */
     $folderMetadata = $dbxClient->getMetadataWithChildren("/");
     print_r($folderMetadata);
     $f = fopen($path . "test.txt", "w+b");
     $fileMetadata = $dbxClient->getFile("/test.txt", $f);
     fclose($f);
     print_r($fileMetadata);
 }
コード例 #11
0
ファイル: dropbox.php プロジェクト: nikosv/openeclass
 private function init() {
     if (!$this->appInfo) {
         $this->appInfo = dbx\AppInfo::loadFromJson(array("key" => $this->getClientID(), "secret" => $this->getSecret()));
     }
 }
コード例 #12
0
<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.";
    }
コード例 #13
0
<?php

if (!isset($_GET['key']) || !isset($_GET['secret']) || !isset($_GET['auth'])) {
    exit;
}
# Include the Dropbox SDK libraries
require_once "lib/Dropbox/autoload.php";
use Dropbox as dbx;
$json_str = '{"key": "' . $_GET['key'] . '","secret": "' . $_GET['secret'] . '"}';
$json_obj = json_decode($json_str, TRUE);
$appInfo = dbx\AppInfo::loadFromJson($json_obj);
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
// START THE AUTHORIZATION PROCEDURE
$authorizeUrl = $webAuth->start();
$authCode = $_GET['auth'];
list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
echo "<div style='text-align:center;font-weight:bold;'>";
echo "Your permanent access token is:<br/>";
echo "<h4 style='color:red;font-size:10px;'>";
echo $accessToken;
echo "</h4>";
echo "<div>";
コード例 #14
0
ファイル: dropbox_sdk_php.php プロジェクト: yfix/yf
#!/usr/bin/php
<?php 
$config = ['git_urls' => ['https://github.com/dropbox/dropbox-sdk-php.git' => 'dropbox-sdk-php/'], 'autoload_config' => ['dropbox-sdk-php/lib/Dropbox/' => 'Dropbox'], 'example' => function () {
    $appInfo = \Dropbox\AppInfo::loadFromJson(json_decode('{"key": "INSERT_APP_KEY_HERE", "secret": "INSERT_SECRET_HERE"}', true));
    $webAuth = new \Dropbox\WebAuthNoRedirect($appInfo, 'PHP-Example/1.0');
    var_dump($webAuth);
}];
if ($return_config) {
    return $config;
}
require_once __DIR__ . '/_yf_autoloader.php';
new yf_autoloader($config);
<?php

use RingCentral\SDK\Http\HttpException;
use RingCentral\http\Response;
use RingCentral\SDK;
use Dropbox as dbx;
echo "\n";
echo "------------Download Call Recordings to Dropbox ----------------";
echo "\n";
try {
    // To parse the .env
    $dotenv = new Dotenv\Dotenv(getcwd());
    $dotenv->load();
    // Dropbox Authentication
    $appInfo = dbx\AppInfo::loadFromJson(array('key' => $_ENV["dropBoxkey"], 'secret' => $_ENV["dropBoxsecret"]));
    $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;