Download the PHP package gothick/php-akismet without Composer
On this page you can find all versions of the php package gothick/php-akismet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gothick/php-akismet
More information about gothick/php-akismet
Files in gothick/php-akismet
Package php-akismet
Short Description Akismet PHP Client
License Apache-2.0
Homepage https://github.com/gothick/phpbb-akismet
Informations about the package php-akismet
php-akismet
A simple PHP Akismet client.
- PSR-4 autoloading
- Composer-friendly
- Uses Guzzle as its http client
- Exposes all Akismet methods and return values
- Available on Packagist
Simple Usage
Spam checking
Uses Akismet's comment-check
API method:
More advanced usage
Verifying your API key
Submitting ham and spam
This client also exposes Akismet's submit-spam
and submit-ham
methods. Use them as
with commentCheck above, passing exactly the same parameters. See the Akismet API
documentation for more details.
Using a custom Guzzle client
If you have particular network transport needs, you may override the default Guzzle client that the Akismet client uses by passing a Guzzle client as the last constructor parameter:
$guzzle_client = new \GuzzleHttp\Client([
'timeout' => 10.0,
'handler' => $my_special_handler_stack
]);
$akismet_client = new \Gothick\AkismetClient\Client(
"http://example.com", // Your website's URL (this becomes Akismet's "blog" parameter)
"Example Forum", // Your website or app's name (Used in the User-Agent: header when talking to Akismet)
"1.2.3", // Your website or app's software version (Used in the User-Agent: header when talking to Akismet)
"YOUR KEY HERE", // Your Akismet API key
$guzzle_client
);
Error handling
The client should either Just Work or throw \Gothick\AkismetClient\AkismetException
,
which is an entirely trivial extension of the PHP \Exception
base class.
Tests
A unit test suite is provided; install the package using Composer with dev requirements, then (you'll need PHP 8.1+ and PHPUnit 10.5+):
You'll notice some tests are skipped. The majority of the tests use mock Guzzle responses, require no network connectivity, and don't touch the Akismet servers. If you wish to run the "live" tests that connect to the API server, provide your API key in an environment variable: