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