title: Use Dropbox API with CodeIgniter
body: <p>Trying to reuse the following Dropbox API code within CodeIgniter. The issue is getting it to work within the constraints of class methods &amp; constuctors:</p>
  
  <pre><code>require_once('../dropbox-sdk-1.1.4/Dropbox/autoload.php');
  use \Dropbox as dbx;
  $accessToken = 'DROPBOX_ACCESSTOKEN';
  $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
  </code></pre>
  
  <p>Needs to be something like the following, but doesn't like the 'use \Dropbox as dbx' line, amongst others:</p>
  
  <pre><code>class Controller_name extends CI_Controller
  {
      public function __construct()
      {
          parent::__construct();
          require_once('../dropbox-sdk-1.1.4/Dropbox/autoload.php');
          use \Dropbox as dbx;
      }
  
      public function access_dropbox()
      {
          $accessToken = 'DROPBOX_ACCESSTOKEN';
          $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
  
          $file = 'file.txt';
  
          $f = fopen( $file, "rb" );
          $result = $dbxClient-&gt;uploadFile( "/$file", dbx\WriteMode::add(), $f);
          fclose($f);
      }
  }
  </code></pre>
  
  <p>Using the code below I'm getting the following error message:</p>
  
  <blockquote>
    <p>An uncaught Exception was encountered</p>
    
    <p>Type: Kunnu\Dropbox\Exceptions\DropboxClientException</p>
    
    <p>Message: Error in call to API function "files/upload": HTTP header
    "Dropbox-API-Arg": path: 'db_backup' did not match pattern
    '(/(.|[\r\n])<em>)|(ns:[0-9]+(/.</em>)?)|(id:.*)'</p>
    
    <p>Filename:
    /opt/lampp/htdocs/codeig-smythes/vendor/kunalvarma05/dropbox-php-sdk/src/Dropbox/Http/Clients/DropboxGuzzleHttpClient.php</p>
    
    <p>Line Number: 59</p>
  </blockquote>
  
  <pre><code>$file_path = 'public/sql_backup/db_backup_' .date("Y-m-d"). '.sql';
  
  require_once('../vendor/autoload.php');
  
  $app = new Kunnu\Dropbox\DropboxApp(
      'APP_KEY',
      'APP_SECRET',
      'ACCESS_TOKEN'
  );
  
  $dropbox = new Kunnu\Dropbox\Dropbox($app);
  $dropboxFile = new Kunnu\Dropbox\DropboxFile(realpath($file_path));
  
  $file = $dropbox-&gt;upload(
      $dropboxFile, basename($file_path), array('autorename' =&gt; TRUE)
  );
  </code></pre>