PHP code example of pear / services_akismet2

1. Go to this page and download the library: Download pear/services_akismet2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pear / services_akismet2 example snippets




e_once 'Services/Akismet2/Comment.php';

$comment = new Services_Akismet2_Comment(
    array(
        'comment_author'       => 'Test Author',
        'comment_author_email' => '[email protected]',
        'comment_author_url'   => 'http://example.com/',
        'comment_content'      => 'Hello, World!'
    )
);

$apiKey  = 'AABBCCDDEEFF';
$akismet = new Services_Akismet2('http://blog.example.com/', $apiKey);
if ($akismet->isSpam($comment)) {
    // rather than simply ignoring the spam comment, it is recommended
    // to save the comment and mark it as spam in case the comment is a
    // false positive.
} else {
    // save comment as normal comment
}