在 Yii 框架中使用 Zend Gdata
我正在尝试从 Zend Gdata 的 Picasa 获取一些照片。这是我的代码:
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't find", 404);
}
return $feed;
}
但是当我运行这个脚本时,我的网站抛出一个错误:
Fatal error: Class 'CExceptionEvent' not found in D:\xampp\htdocs\yii\framework\base\CApplication.php on line 703
你能帮我解决这个问题吗?非常感谢。
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't 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题的原因是您抛出了一个异常(可能是代码末尾附近的
HttpException
),并且 Yii 想要构造一个CExceptionEvent
实例,以便它可以引发CApplication::onException
事件。然而,Yii 的类自动加载器已从自动加载堆栈中删除,因此 PHP 无法找到该类。
尝试注释掉删除和添加 Yii 自动加载器的代码,看看是否有区别:
您还可以调用
spl_autoload_functions
来检查你的 spl_autoload 堆栈到底发生了什么——也许有什么东西损坏了它: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 aCExceptionEvent
instance so that it can raise theCApplication::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:
You can also call
spl_autoload_functions
to check what exactly is going on with your spl_autoload stack -- maybe something has corrupted it: