Akismet PHP plugin
Plugin for Akismet API
How to use:
-
Add to composer.json:
{ "require": { "createanduse/akismet": "@stable" } }
-
Run:
composer update
-
In your code:
use CreateAndUse\Akismet\Akismet; ... $akismet = new Akismet($apiKey, $appUrl);
-
Verify key:
$isVerified = $akismet->verifyKey();
-
Check comment:
$params = [ 'user_ip' => '127.0.0.1', 'user_agent' => 'User-Agent', 'referrer' => 'http://website.lan', 'permalink' => 'http://website.lan', 'comment_type' => 'comment', 'comment_author' => 'username', 'comment_author_email' => 'john@doe.org', 'comment_author_url' => 'http://website.lan', 'comment_content' => 'comment', 'blog_lang' => 'pl', 'blog_charset' => 'UTF-8', ]; $isSpam = $akismet->commentCheck($params);
More info about params:
https://akismet.com/development/api/#comment-check