コード例 #1
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';
             }
         }
     }
 }
コード例 #2
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);
 }
コード例 #3
0
 public function dropbox()
 {
     //return Input::file('uploadfile');
     //return $uploadfile = Input::file('uploadfile');
     //use \Dropbox as dbx;
     $appInfo = \Dropbox\AppInfo::loadFromJsonFile("app_info.json");
     $webAuth = new \Dropbox\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
     $authorizeUrl = $webAuth->start();
     $accessToken = "LUu8h-uvauAAAAAAAAAAHbDw-bulVL7u8BoRAJtedc0-eCDY-Xj4Qxf1iGucUN7j";
     $dbxClient = new \Dropbox\Client($accessToken, "PHP-Example/1.0");
     $accountInfo = $dbxClient->getAccountInfo();
     //  $dbxClient->getAccessToken();
     //return  $dbxClient->_getMetadata("/participant/Fl0dsItC_Airtel.png");
     $host = $dbxClient->getHost();
     return $this->fetchUrl("/participant/Fl0dsItC_Airtel.png");
     //$appendFilePath =  $dbxClient->appendFilePath();
     //print_r($appendFilePath);
     /*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";  */
     /*$f = fopen(url()."/public/assets/upload/contest_theme_photo/Fl0dsItC_Airtel.png", "rb");
     $result = $dbxClient->uploadFile("/participant/Fl0dsItC_Airtel.png", \Dropbox\WriteMode::add(), $f);
     fclose($f);*/
     $f = fopen("Fl0dsItC_Airtel.png", "w+b");
     $fileMetadata = $dbxClient->getFile("/participant/Fl0dsItC_Airtel.png", $f);
     //return $dbxClient->getMetadata("/participant/Fl0dsItC_Airtel.png");
     fclose($f);
     //return View::make('dropbox/dropbox');
 }
コード例 #4
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));
 }
コード例 #5
0
ファイル: common.php プロジェクト: brijendratiwari/csv
function getWebAuth()
{
    $appInfo = dbx\AppInfo::loadFromJsonFile("app-info.json");
    $clientIdentifier = "my-app/1.0";
    $redirectUri = "http://localhost/csv/authfinish.php";
    $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
    return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore);
}
コード例 #6
0
 function tryAppJsonServer($str)
 {
     file_put_contents("test.json", $str);
     $appInfo = dbx\AppInfo::loadFromJsonFile("test.json");
     $this->assertEquals($appInfo->getHost()->getContent(), "api-content-test.droppishbox.com");
     $this->assertEquals($appInfo->getHost()->getApi(), "api-test.droppishbox.com");
     $this->assertEquals($appInfo->getHost()->getWeb(), "meta-test.droppishbox.com");
 }
コード例 #7
0
ファイル: getWebAuth.php プロジェクト: shpikyliak/demoDropbox
function getWebAuth()
{
    $appInfo = dbx\AppInfo::loadFromJsonFile(__DIR__ . '/../test.json');
    $clientIdentifier = "my-app/1.0";
    $redirectUri = "http://localhost:8888/classes/Auth2.php";
    $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
    return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore, 'en');
}
コード例 #8
0
ファイル: link_dropbox.php プロジェクト: alin96/MergeBox
 function getWebAuth()
 {
     $appInfo = dbx\AppInfo::loadFromJsonFile("../lib/Dropbox/app-info.json");
     $clientIdentifier = "my-app/1.0";
     $redirectUri = "http://localhost/link_accounts.php?refer=Dropbox";
     $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
     return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore, "en");
 }
コード例 #9
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;
     }
 }
コード例 #10
0
ファイル: ConfigLoadTest.php プロジェクト: kostya1017/our
 function testAppJsonServer()
 {
     $correct = array("key" => "an_app_key", "secret" => "an_app_secret", "access_type" => "AppFolder", "host" => "test.droppishbox.com");
     file_put_contents("test.json", json_encode($correct, true));
     $appInfo = dbx\AppInfo::loadFromJsonFile("test.json");
     $this->assertEquals($appInfo->getHost()->getContent(), "api-content-test.droppishbox.com");
     $this->assertEquals($appInfo->getHost()->getApi(), "api-test.droppishbox.com");
     $this->assertEquals($appInfo->getHost()->getWeb(), "meta-test.droppishbox.com");
 }
コード例 #11
0
ファイル: DropboxController.php プロジェクト: alin96/MergeBox
 public function getWebAuth()
 {
     session_start();
     $appInfo = dbx\AppInfo::loadFromJsonFile("../resources/assets/app-info.json");
     $clientIdentifier = "my-app/1.0";
     $redirectUri = "http://localhost/api/link/dropbox";
     $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
     return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore, "en");
 }
コード例 #12
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");
 }
コード例 #13
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);
 }
コード例 #14
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;
 }
コード例 #15
0
 public function dropboxAuth()
 {
     session_start();
     $appInfo = dbx\AppInfo::loadFromJsonFile(__DIR__ . "\\app-info.json");
     $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
     $webAuth = new dbx\WebAuth($appInfo, "PHP-Example/1.0", 'http://localhost:8080/CloudSync/public/FacebookModel.php', $csrfTokenStore);
     $authorizeUrl = $webAuth->start();
     header('Location: ' . $authorizeUrl);
     exit;
 }
コード例 #16
0
 public function __construct($appInfoFilePath, &$session)
 {
     try {
         $appInfo = \Dropbox\AppInfo::loadFromJsonFile($appInfoFilePath);
     } catch (\Dropbox\AppInfoLoadException $ex) {
         throw new Exception("Unable to load \"{$appInfoFilePath}\": " . $ex->getMessage());
     }
     $this->appInfo = $appInfo;
     $this->session =& $session;
 }
コード例 #17
0
 private function getWebAuth()
 {
     $appInfo = dbx\AppInfo::loadFromJsonFile("dropbox_api.json");
     //$session = Session::all();
     //Session::reflash();
     session_start();
     $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, "dropbox-auth-csrf-token");
     //echo var_dump($csrfTokenStore);
     //exit;
     return new dbx\WebAuth($appInfo, $this->_appName, "http://localhost/laravelhurrdurr/public/dropboxauth", $csrfTokenStore);
 }
コード例 #18
0
ファイル: s_carpetas.php プロジェクト: alexlqi/multidev
function crearCarpeta($folio, $tipo = "PREVIO")
{
    $empresaSes = str_replace(" ", "_", $_SESSION["empresa"]);
    global $cliente_id;
    //cliente de dropbox
    try {
        $appInfo = dbx\AppInfo::loadFromJsonFile("../includes/Dropbox/config.json");
        $accessToken = "jxxJCQnl2ykAAAAAAAAAGRmgdiFo8REFSCcJ-sb19QyT2lPiEEV8g7GiyB2booGP";
        // desde la pagina de app console
        $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
        $root = "/examenes";
        $empresa = "/" . $empresaSes;
        $folder = "/" . $folio;
        //este va a ser el folio del paciente
        $path = $root . $empresa . $folder;
        //creamos el folder
        $createFolder = $dbxClient->createFolder($path);
        //subimos los archivos si se creó el folder
        if ($createFolder) {
            if ($cliente_id == 479) {
                $files_root = "../archivos";
                $files_emp = "/{$empresaSes}";
                $files_type = "/{$tipo}";
                $files_path = $files_root . $files_emp . $files_type;
                foreach (scandir($files_path) as $d) {
                    if ($d == "." || $d == "..") {
                        continue;
                    }
                    $archivos[] = array("filename" => $path . "/" . $d, "file" => file_get_contents("{$files_path}/{$d}"));
                }
            } else {
                switch ($tipo) {
                    case 'PREVIO':
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Radiografias.xlsx")));
                        break;
                    case 'STAFF':
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Radiografias.xlsx")));
                        break;
                    case 'OPERARIO':
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Audiometria.xlsx")), array("filename" => $path . "/Fuerza_Equilibrio.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Fuerza_Equilibrio.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Radiografias.xlsx")));
                        break;
                    default:
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Radiografias.xlsx")));
                        break;
                }
            }
            foreach ($archivos as $d) {
                $dbxClient->uploadFileFromString($d["filename"], dbx\WriteMode::add(), $d["file"]);
            }
        }
    } catch (Exception $e) {
    }
}
コード例 #19
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);
 }
コード例 #20
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;
 }
コード例 #21
0
            fwrite(STDERR, "Unrecognized option \"{$arg}\".\n");
            fwrite(STDERR, "Run with no arguments for help\n");
        }
    } else {
        array_push($remainingArgs, $arg);
    }
}
if (count($remainingArgs) !== 3) {
    fwrite(STDERR, "Expecting exactly 3 non-option arguments, got " . count($remainingArgs) . "\n");
    fwrite(STDERR, "Run with no arguments for help\n");
    die;
}
$appInfoFile = $remainingArgs[0];
$oauth1AccessToken = new dbx\OAuth1AccessToken($remainingArgs[1], $remainingArgs[2]);
try {
    list($appInfoJson, $appInfo) = dbx\AppInfo::loadFromJsonFileWithRaw($appInfoFile);
} catch (dbx\AppInfoLoadException $ex) {
    fwrite(STDERR, "Error loading <app-info-file>: " . $ex->getMessage() . "\n");
    die;
}
// Get an OAuth 2 access token.
$upgrader = new dbx\OAuth1Upgrader($appInfo, "examples-authorize", "en");
$oauth2AccessToken = $upgrader->createOAuth2AccessToken($oauth1AccessToken);
echo "OAuth 2 access token obtained.\n";
// Write out auth JSON.
$authArr = array("access_token" => $oauth2AccessToken);
if (array_key_exists('host', $appInfoJson)) {
    $authArr['host'] = $appInfoJson['host'];
}
$json_options = 0;
if (defined('JSON_PRETTY_PRINT')) {
コード例 #22
0
ファイル: init.php プロジェクト: russtx/tac
 public static function init()
 {
     require_once pb_backupbuddy::plugin_path() . '/destinations/dropbox2/lib/Dropbox/autoload.php';
     self::$appInfo = dbx\AppInfo::loadFromJsonFile(pb_backupbuddy::plugin_path() . '/destinations/dropbox2/_config.json');
 }
コード例 #23
0
<?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;
コード例 #24
0
ファイル: dropbox.php プロジェクト: nikosv/openeclass
 private function init() {
     if (!$this->appInfo) {
         $this->appInfo = dbx\AppInfo::loadFromJson(array("key" => $this->getClientID(), "secret" => $this->getSecret()));
     }
 }
コード例 #25
0
function getAppConfig()
{
    global $appInfoFile;
    try {
        $appInfo = dbx\AppInfo::loadFromJsonFile($appInfoFile);
    } catch (dbx\AppInfoLoadException $ex) {
        throw new Exception("Unable to load \"{$appInfoFile}\": " . $ex->getMessage());
    }
    $clientIdentifier = "examples-web-file-browser";
    $userLocale = null;
    return array($appInfo, $clientIdentifier, $userLocale);
}
コード例 #26
0
<?php

require_once "dropbox-sdk/Dropbox/autoload.php";
use Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("/app.json");
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
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: "));
コード例 #27
0
ファイル: cloud.php プロジェクト: sass-team/sass-app
// redirect if user elevation is not that of admin
if (!$user->isAdmin()) {
    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) {
コード例 #28
0
ファイル: auth.php プロジェクト: ardeelete/FileRequester
<?php

# Include the Dropbox SDK libraries
require_once "vendor/dropbox-sdk/Dropbox/autoload.php";
use Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("INSERT_PATH_TO_JSON_CONFIG_PATH");
$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");
$accountInfo = $dbxClient->getAccountInfo();
print_r($accountInfo);
$f = fopen("working-draft.txt", "rb");
$result = $dbxClient->uploadFile("/working-draft.txt", dbx\WriteMode::add(), $f);
fclose($f);
print_r($result);
$folderMetadata = $dbxClient->getMetadataWithChildren("/");
print_r($folderMetadata);
$f = fopen("working-draft.txt", "w+b");
$fileMetadata = $dbxClient->getFile("/working-draft.txt", $f);
fclose($f);
print_r($fileMetadata);
 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);
 }
コード例 #30
0
ファイル: authorize.php プロジェクト: jkphl/edropub
     throw new \Exception('This program was meant to be run from the command-line and not as a web app. Bad value for PHP_SAPI. Expected \'cli\', given \'' . PHP_SAPI . '\'.', 1);
 }
 // Make sure the Dropbox SDK has been installed
 if (!@is_dir(dirname(__DIR__) . '/vendor/dropbox/dropbox-sdk')) {
     throw new \Exception('Please install the Dropbox SDK by running \'composer install\' in the edropub root directory.', 2);
 }
 // Require common settings
 require_once dirname(__DIR__) . '/config/common.php';
 // Activate error reporting
 require_once dirname(__DIR__) . '/vendor/dropbox/dropbox-sdk/lib/Dropbox/strict.php';
 // Include the Dropbox autoloader in case the composer autoloader is not already active
 if (!class_exists('\\Dropbox\\AppInfo')) {
     echo "auto\n\n";
     require_once dirname(__DIR__) . '/vendor/dropbox/dropbox-sdk/lib/Dropbox/autoload.php';
 }
 list($appInfoJson, $appInfo) = \Dropbox\AppInfo::loadFromJsonFileWithRaw(dirname(__DIR__) . '/config/config.json');
 // This is a command-line tool (as opposed to a web app), so we can't supply a redirect URI.
 $webAuth = new \Dropbox\WebAuthNoRedirect($appInfo, "examples-authorize", "en");
 $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";
 echo "Enter the authorization code here: ";
 $authCode = \trim(\fgets(STDIN));
 list($accessToken, $userId) = $webAuth->finish($authCode);
 echo "Authorization complete.\n";
 echo "- User ID: {$userId}\n";
 echo "- Access Token: {$accessToken}\n";
 $authArr = array('access_token' => $accessToken, 'editorially_prefix' => '/Apps/Editorially', 'leadpub_api_key' => '<YOUR_ACCOUNT_API_KEY>', 'leadpub_prefix' => '/<YOUR_BOOKS_SLUG>', 'leanpub_trigger' => 'preview');
 if (array_key_exists('host', $appInfoJson)) {
     $authArr['host'] = $appInfoJson['host'];