Larakismet
, (*1)
Akismet Client for Laravel 5., (*2)
Installation
simply include this library to your app's composer.json file in the request block:, (*3)
"require": {
"eman1986/larakismet": "dev-master",
}
Once you have the package loaded into your application's file system, open the config/app.php file and add the following line to the 'providers' array:, (*4)
'larakismet\ServiceProviders\AkismetServiceProvider'
Add the facade of this package to the $aliases array., (*5)
'Akismet' => 'larakismet\Facades\Akismet'
run the following command in your terminal:, (*6)
php artisan vendor:publish
This will create a config file for you where you can enter in the API Key (which if you don't have one, you'll need one, visit https://akismet.com)
and enter in the address of your blog. You can also setup a debug mode to just test out the akismet API., (*7)
What's Next?
After everything is all configured, you can now use the code in your application., (*8)
checkSpam()
This will allow you to run a check on a comment post and ensure its not spam., (*9)
Akismet likes to have as much information as possible to properly determine if something is indeed Spam., (*10)
If you were to read the Akismet API on this, they ask for a lot of things but at a minimal you'll need the following set:, (*11)
\Akismet::setCommentAuthor('John Doe');
\Akismet::setCommentAuthorEmail('email@example.com');
\Akismet::setPermalink('http://somesite.com/blog/sample-entry');
\Akismet::setCommentContent('Some content from form.');
\Akismet::checkSpam();
If you check out the source code you can see the other options available to zero in on the spammer, the Akismet API Guide is also a good reference.., (*12)
reportSpam()
You can help Akismet tackle spam by reporting it to them, this requires a smaller set of dat compared to the checkSpam() method., (*13)
\Akismet::setCommentAuthor('John Doe');
\Akismet::setCommentAuthorEmail('email@example.com');
\Akismet::setPermalink('http://somesite.com/blog/sample-entry');
\Akismet::setCommentContent('Some content from form.');
\Akismet::reportSpam();
reportHam()
You can also report false positives to Akismet by doing the following:, (*14)
\Akismet::setCommentAuthor('John Doe');
\Akismet::setCommentAuthorEmail('email@example.com');
\Akismet::setPermalink('http://somesite.com/blog/sample-entry');
\Akismet::setCommentContent('Some content from form.');
\Akismet::reportHam();
ReportSpam() & reportHam() will accept the same parameters. Using these two methods will help make the web a better place for all of us., (*15)
Questions?
If you need help, please let me know and I'll be happy to assist., (*16)