Skip to content

Key verification

Key verification authenticates your key before calling the comment check, submit spam or submit ham methods.

Client->verifyKey(): bool

This is the first call that you should make to Akismet and is especially useful if you will have multiple users with their own Akismet subscriptions using your application.

See the Akismet API documentation for more information.



Return value

A bool value indicating whether the client's API key is valid.

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.


use yii\akismet\{Client, ClientException};

try {
    $client = new Client([
        "apiKey" => "123YourAPIKey",
        "blog" => ""

    $isValid = $client->verifyKey();
    print $isValid ? "The API key is valid." : "The API key is invalid.";

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