开发者

Using Zend Gdata in Yii framework

I am trying to fetch some photos from Picasa by Zend Gdata. This is my code:

public function getAlbumFeed($albumName){
    require_once('Zend/Loader.php');
    spl_autoload_unregister(array('YiiBase','autoload'));
    spl_autoload_register(array('Zend_Loader_Autoloader','autoload'));
    spl_autoload_register(array('YiiBase','autoload'));
    Zend_Loader::loadClass('Zend_Gdata');
    Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
    Zend_Loader::loadClass('Zend_Gdata_Photos');
    Zend_Loader::loadClass('Zend_Http_Client');

    $svc=Zend_Gdata_Photos::AUTH_SERVICE_NAME;
    $client=Zend_Gdata_ClientLogin::getHttpClient($this->email, $this->password, $svc);
    $gphoto=new Zend_Gdata_Photos($client);

    $query=$gphoto->newAlbumQuery();
    $query->setUser('default');
    $query->setAlbumName($albumName);

    try{
        $feed=$gphoto->getAlbumFeed($query);
    }
    catch(Zend_Gdata_App_Exception $e){
        throw new HttpException("Your photos can'开发者_如何学JAVAt find", 404);
    }
    return $feed;
}

But when I run this script, my website throw a error:

Fatal error: Class 'CExceptionEvent' not found in D:\xampp\htdocs\yii\framework\base\CApplication.php on line 703

Could you help me to solve this problem? Thank you very much.


The cause of the problem is that you are getting an exception thrown (probably that HttpException near the end of your code), and Yii wants to construct a CExceptionEvent instance so that it can raise the CApplication::onException event.

However, Yii's class autoloader has been removed from the autoload stack and as a result PHP cannot find the class.

Try commenting out the code that removes and adds Yii's autoloader and see if it makes a difference:

// spl_autoload_unregister(array('YiiBase','autoload'));
spl_autoload_register(array('Zend_Loader_Autoloader','autoload'));
// spl_autoload_register(array('YiiBase','autoload'));

You can also call spl_autoload_functions to check what exactly is going on with your spl_autoload stack -- maybe something has corrupted it:

print_r(spl_autoload_functions());
die;  // see what the line above prints

$svc=Zend_Gdata_Photos::AUTH_SERVICE_NAME;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜