This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 69be803603ef440f4cc7d0e6319641ac016248cb
tree e60a50275a1d3a728163a2c0caa84343325d7240
parent fd0e5ad625cb21f5ba16e6b186821a5774089ac7
tree e60a50275a1d3a728163a2c0caa84343325d7240
parent fd0e5ad625cb21f5ba16e6b186821a5774089ac7
| name | age | message | |
|---|---|---|---|
| .. | |||
| |
akismet_source.php | Mon Sep 01 07:14:30 -0700 2008 | |
| |
readme.textile | Mon Sep 01 05:53:36 -0700 2008 |
cakephp/datasources/akismet/readme.textile
CakePHP Amazon Associates Data Source
A CakePHP datasource for interacting with the Akismet spam protection API.
If you don’t have an Akismet API key you can get one here: Get Akismet API key
Usage / Docs
1. Copy akismet_source.php to app/models/datasources/
2. Open your app/config/database.php and add the following:
var $akismet = array(
'datasource' => 'akismet',
'blog' => 'http://your-website-url.com',
'key' => 'your-api-key-here',
'map' => array(
'comment_author' => 'author_name',
'comment_author_email' => 'author_email',
'comment_author_url' => 'author_url',
'user_ip' => 'author_ip',
'user_agent' => 'author_agent',
'comment_type' => 'type',
'comment_content' => 'text',
)
);
The map key above tells the API what model fields of yours map to what fields the API expects to receive. If you use this API with multiple models you can dynamically pass different maps upon each request, or perform the normalization yourself before passing your data to the datasource.
3. Add this validation logic to your Comment model:
class Comment extends AppModel{
var $validate = array(
'text' => array(
array(
'rule' => array('notSpam'),
'message' => 'This comment appears to be spam. Please contact us if the problem persists.',
'required' => true,
),
),
);
function notSpam($fields) {
$akismet = ConnectionManager::getDataSource('akismet');
return !$akismet->isSpam($this->data['Comment'], Post::url($this->data['Comment']['post_id']));
}
}
Known Bugs
None







