1
votes

Has anyone any idea how to tie in the dropbox php api http://code.google.com/p/dropbox-php/ in Yii. I downloaded the source files and put in ext.dropbox and then inserted the following code

     $dropbox = Yii::getPathOfAlias('ext.dropbox');
     spl_autoload_unregister(array('YiiBase','autoload'));     
     Yii::registerAutoloader(array('Dropbox_autoload','autoload'));
       $consumerKey = '***';
       $consumerSecret = '***';
       $oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret);

       try {
           $oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret);
           $dropbox = new Dropbox_API($oauth);             
           $info = $dropbox->getMetaData('Files');
       } catch (Exception $e) {
           $error = "error: " . $e->getMessage();
       }

       spl_autoload_register(array('YiiBase','autoload'));

I get the error Fatal error: Class 'CExceptionEvent' not found in *

2

2 Answers

0
votes

Try this one:

$dropbox = Yii::getPathOfAlias('ext.dropbox');
     spl_autoload_unregister(array('YiiBase','autoload'));    
     Yii::registerAutoloader(array('Dropbox_autoload','autoload'));
       $consumerKey = '***';
       $consumerSecret = '***';
       $oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret);

       try {
           $oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret);
           $dropbox = new Dropbox_API($oauth);            
           $info = $dropbox->getMetaData('Files');
       } catch (Exception $e) {
           $error = "error: " . $e->getMessage();
       }

       spl_autoload_register(array('YiiBase','autoload'));

Yii::import('swift.classes.Swift', true);
Yii::registerAutoloader(array('Swift','autoload'));
Yii::import('swift.swift_init', true);

Yii::setPathOfAlias('swift', '/var/www/lib');

Also there is a API libary for download in this Dropbox Lib and also a PHP 5.3 SDK for the Dropbox REST API

3
votes

I'm not sure about Dropbox specifically, but this is how I included SwiftMailer:

Yii::import('swift.classes.Swift', true);
Yii::registerAutoloader(array('Swift','autoload'));
Yii::import('swift.swift_init', true);

where the setPathOfAlias looks like:

Yii::setPathOfAlias('swift', '/var/www/lib');

(I'm using it for other apps, which is why it isn't in the Yii tree. Other libs I keep in the extensions dir and for simple ones, a basic "import" is often enough.)