Key verification
Key verification authenticates your API key before calling the comment check, submit spam or submit ham methods.
<?php 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.
Parameters
None.
Return value
A bool
value indicating whether the client's API key is valid.
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
<?php
use akismet\{Blog, Client};
try {
$blog = new Blog("https://www.yourblog.com");
$client = new Client("123YourAPIKey", $blog);
$isValid = $client->verifyKey();
print $isValid ? "The API key is valid." : "The API key is invalid.";
}
catch (RuntimeException $e) {
print "An error occurred: {$e->getMessage()}";
}
See the API reference for detailed information about the Client
and Blog
classes, and their properties and methods.