public function runAction($action)
 {
     Yii::app()->onEndRequest = array($this, 'endRequest');
     if (@strlen(Yii::app()->params['api_ips']) && !Yii::app()->user->checkIp(Yii::app()->params['api_ips'])) {
         Yii::log('API access denied (IP ' . Yii::app()->user->ip . ')');
         $this->end('API access denied');
     }
     $this->validateKey();
     try {
         parent::runAction($action);
     } catch (ReflectionException $e) {
         $this->end('Invalid API call.');
     } catch (Exception $e) {
         $this->end($e->getMessage());
     }
     $this->end();
 }