Example #1
0
 /**
  * Creates a new Akismet object.
  *
  * @param   array  configuration
  * @return  void
  */
 public function __construct(array $comment, array $config = array())
 {
     // Load configuration from Akismet config file
     $this->_config = Kohana::$config->load('akismet');
     // Set base URL of page, required to verification.
     $this->_config['blog'] = URL::base(TRUE);
     // Add/overwrite with custom config values
     $this->setup($config);
     // Load and fill comments values.
     $this->_comment = $comment;
     $this->fill_comments_value();
     // Set user agent string
     Akismet::$_user_agent = 'Kohana/' . Kohana::VERSION . ' | Akismet/' . Akismet::AKISMET_VERSION;
     // Verify key
     if ($this->verify_key()) {
         $this->_key = $this->_config['key'];
     } else {
         throw new Exception("Your Akismet API key is not valid.");
     }
 }