Skip to content

Submit ham

This call is intended for the submission of false positives - items that were incorrectly classified as spam by Akismet. It takes identical arguments as comment check and submit spam.

Client->submitHam(Comment $comment): void

Remember that, as explained in the submit spam documentation, you should ensure that any values you're passing here match up with the original and corresponding comment check call.

See the Akismet API documentation for more information.

Parameters

Comment $comment

The user Comment to be submitted, incorrectly classified as spam.

Tip

Ideally, it should be the same object as the one passed to the original comment check API call.

Return value

None.

The method throws a ClientException when an error occurs. The exception getMessage() usually includes some debug information, provided by the X-akismet-debug-help HTTP header, about what exactly was invalid about the call.

Example

<?php
use yii\akismet\{Author, Client, ClientException, Comment};

try {
    $client = new Client([
        "apiKey" => "123YourAPIKey",
        "blog" => "http://www.yourblog.com"
    ]);

    $comment = new Comment(
        new Author("127.0.0.1", "Mozilla/5.0"),
        ["content" => "A valid user comment (ham)"]
    );

    $result = $client->checkComment($comment); // `true`, but `false` expected.
        // Got `CheckResult::isSpam`, but `CheckResult::isHam` expected.

    print "The comment was incorrectly classified as spam.";
    $client->submitHam($comment);
}

catch (ClientException $e) {
    print "An error occurred: {$e->getMessage()}"
}