Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include 'akismet.class.php';
- // Load array with comment data.
- $comment = array(
- 'author' => 'viagra-test-123',
- 'email' => 'test@example.com',
- 'website' => 'http://www.example.com/',
- 'body' => 'This is a test comment',
- 'permalink' => 'http://your-domain.com/path-to-your-comment-page',
- 'user_ip' => 'an-ip-address', // Optional, if not in array defaults to $_SERVER['REMOTE_ADDR'].
- 'user_agent' => 'user-agent-string', // Optional, if not in array defaults to $_SERVER['HTTP_USER_AGENT'].
- );
- // Instantiate an instance of the class.
- $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);
- // Test for errors.
- if($akismet->errorsExist()) { // Returns true if any errors exist.
- if($akismet->isError('AKISMET_INVALID_KEY')) {
- // Do something.
- } elseif($akismet->isError('AKISMET_RESPONSE_FAILED')) {
- // Do something.
- } elseif($akismet->isError('AKISMET_SERVER_NOT_FOUND')) {
- // Do something.
- }
- } else {
- // No errors, check for spam.
- if ($akismet->isSpam()) { // Returns true if Akismet thinks the comment is spam.
- // Do something with the spam comment.
- } else {
- // Do something with the non-spam comment.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement