/**
* Handling user-posted comments
*/
$comment->setAuthor('Test Author');
$comment->setAuthorEmail('test@example.com');
$comment->setAuthorUri('http://example.com/');
$comment->setContent('Hello, World!');
try {
$apiKey = 'AABBCCDDEEFF';
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
}
echo 'Invalid API key!';
echo 'Error communicating with Akismet API server: ' .
$comException->getMessage();
echo 'Specified comment is missing one or more required fields.' .
$commentException->getMessage();
}
/**
* Submitting a comment as known spam
*/
$comment->setAuthor('Test Author');
$comment->setAuthorEmail('test@example.com');
$comment->setAuthorUri('http://example.com/');
$comment->setContent('Hello, World!');
try {
$apiKey = 'AABBCCDDEEFF';
echo 'Invalid API key!';
echo 'Error communicating with Akismet API server: ' .
$comException->getMessage();
echo 'Specified comment is missing one or more required fields.' .
$commentException->getMessage();
}
/**
* Submitting a comment as a false positive
*/
$comment->setAuthor('Test Author');
$comment->setAuthorEmail('test@example.com');
$comment->setAuthorUri('http://example.com/');
$comment->setContent('Hello, World!');
try {
$apiKey = 'AABBCCDDEEFF';
echo 'Invalid API key!';
echo 'Error communicating with Akismet API server: ' .
$comException->getMessage();
echo 'Specified comment is missing one or more required fields.' .
$commentException->getMessage();
}