コード例 #1
0
ファイル: upload.php プロジェクト: xingskycn/p2-php
 /**
  * @param string $authJsonFile
  * @param string $clientIdentifier
  * @param string $prefix
  */
 public function __construct($authJsonFile, $clientIdentifier, $prefix)
 {
     $pathError = Dropbox\Path::findError($prefix . 'check');
     if ($pathError !== null) {
         throw new RuntimeException("Dropbox upload prefix error: {$pathError}");
     }
     list($appInfo, $accessToken) = Dropbox\AuthInfo::loadFromJsonFile($authJsonFile);
     $config = new Dropbox\Config($appInfo, $clientIdentifier);
     $this->client = new Dropbox\Client($config, $accessToken);
     $this->prefix = sprintf('%s%x', $prefix, time());
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: kostya1017/our
 public function actionGetdropboxlink($path)
 {
     $path = base64_decode($path);
     $pathError = Dropbox\Path::findError($path);
     if ($pathError !== null) {
         throw new CHttpException(500, "Invalid <dropbox-path>: {$pathError}\n");
     }
     $client = new Dropbox\Client(Yii::app()->params['dropboxToken'], 'dropbox-client');
     $link = $client->createTemporaryDirectLink($path);
     echo CJSON::encode($link);
     Yii::app()->end();
 }
コード例 #3
0
ファイル: dropbox.catalog.php プロジェクト: axelsimon/ampache
 /**
  * create_type
  *
  * This creates a new catalog type entry for a catalog
  * It checks to make sure its parameters is not already used before creating
  * the catalog.
  */
 public static function create_type($catalog_id, $data)
 {
     $apikey = $data['apikey'];
     $secret = $data['secret'];
     $path = $data['path'];
     $getchunk = $data['getchunk'];
     if (!strlen($apikey) or !strlen($secret)) {
         Error::add('general', T_('Error: API Key and Secret Required for Dropbox Catalogs'));
         return false;
     }
     $pathError = Dropbox\Path::findError($path);
     if ($pathError !== null) {
         Error::add('general', T_('Invalid <dropbox-path>: ' . $pathError));
         return false;
     }
     // Make sure this app isn't already in use by an existing catalog
     $sql = 'SELECT `id` FROM `catalog_dropbox` WHERE `apikey` = ?';
     $db_results = Dba::read($sql, array($apikey));
     if (Dba::num_rows($db_results)) {
         debug_event('catalog', 'Cannot add catalog with duplicate key ' . $apikey, 1);
         Error::add('general', sprintf(T_('Error: Catalog with %s already exists'), $apikey));
         return false;
     }
     $sql = 'INSERT INTO `catalog_dropbox` (`apikey`, `secret`, `path`, `getchunk`, `catalog_id`) VALUES (?, ?, ?, ?, ?)';
     Dba::write($sql, array($apikey, $secret, $path, $getchunk ? 1 : 0, $catalog_id));
     return true;
 }