Skip to content

Submit ham

Cédric Belin edited this page Jun 15, 2024 · 3 revisions

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's Comment to be submitted, incorrectly classified as spam.

Note

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 RuntimeException 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.

It can also throw a custom error code and message (respectively provided by the X-akismet-alert-code and X-akismet-alert-msg headers). See Response Error Codes for more information.

Example

use akismet\{Author, Blog, Client, Comment};

try {
  $blog = new Blog("https://www.yourblog.com");
  $client = new Client("123YourAPIKey", $blog);

  $comment = new Comment(
    content: "I'm testing out the Service API.",
    author: new Author(
      ipAddress: "192.168.123.456",
      userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0"
    )
  );

  $client->submitHam($comment);
  print("The comment was successfully submitted as ham.");
}
catch (RuntimeException $e) {
  print "An error occurred: {$e->getMessage()}";
}
Clone this wiki locally