Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Akismet Component for Yii Framework
branch: master

This branch is even with chemezov:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Akismet.class.php
AkismetComponent.php
README.md

README.md

AkismetComponent

Akismet Component for Yii Framework. Based on https://github.com/achingbrain/php5-akismet

Introduction

This is a simple Yii Framework component that enables you use the Akismet anti-spam service in your yii application.

Download

Check out the git repository:

git clone git@github.com:chemezov/AkismetComponent.git

Installation

Once you have cloned the repo (see Download, above) copy the files at ext.akismet.*.

Before you can use Akismet, you need a WordPress API key (they are free and getting one takes about five minutes).

Change your config file:

// application components
'components'        => array(
  ...
  'akismet'       => array(
    'class'   => 'ext.akismet.AkismetComponent',
    'blogUrl' => 'your_blog_url',
    'apiKey'  => 'your_api_key',
  ),
  ...
)

Documentation

See the PHPDocs.

Usage

$akismet = Yii::app()->akismet;
$akismet->setCommentAuthor($name);
$akismet->setCommentAuthorEmail($email);
$akismet->setCommentAuthorURL($url);
$akismet->setCommentContent($comment);
$akismet->setPermalink('http://www.example.com/blog/alex/someurl/');

if($akismet->isCommentSpam())
  // store the comment but mark it as spam (in case of a mis-diagnosis)
else
  // store the comment normally

That's just about it. In the event that the filter wrongly tags messages, you can at a later date create a new object and populate it from your database, overriding fields where necessary and then use the following two methods to train it:

$akismet->submitSpam();

and

$akismet->submitHam();

to submit mis-diagnosed spam and ham, which improves the system for everybody. See the included documentation for a complete run-down of all available methods.

Changelog

Version 0.1

Initial release

Something went wrong with that request. Please try again.