1. Go to this page and download the library: Download reddingwebdev/abuseipdb library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
reddingwebdev / abuseipdb example snippets
use AbuseIpDb\AbuseIpDbClient;
$client = new AbuseIpDbClient('YOUR_API_KEY');
use AbuseIpDb\Enum\ReportCategory;
$result = $client->report(
'127.0.0.1',
[ReportCategory::SSH, ReportCategory::BRUTE_FORCE],
'SSH login attempts with user root.',
new \DateTimeImmutable()
);
$result->getAbuseConfidenceScore();
use AbuseIpDb\Exception\AbuseIpDbException;
use AbuseIpDb\Exception\RateLimitExceededException;
try {
$result = $client->check($ip);
} catch (RateLimitExceededException $e) {
sleep($e->getRetryAfter() ?? 60);
} catch (AbuseIpDbException $e) {
// log and fail open/closed
}
$client->check($ip);
$rateLimit = $client->getLastRateLimit(); // null before the first call
$rateLimit->getLimit();
$rateLimit->getRemaining();
$rateLimit->getResetAt(); // ?DateTimeImmutable
use AbuseIpDb\AbuseIpDbClient;
$client = new AbuseIpDbClient('YOUR_API_KEY', $psr18Client, $requestFactory, $streamFactory, [
'logger' => $psr3Logger, // optional PSR-3 logger
'default_max_age_in_days' => 30, // used by check/reports/checkBlock when maxAgeInDays is omitted
'base_uri' => 'https://api.abuseipdb.com/api/v2/',
]);
use AbuseIpDb\AbuseIpDbClient;
final class IpGuard
{
public function __construct(private AbuseIpDbClient $abuseIpDb) {}
}
final class AbuseReportCommand
{
public function __construct(private string $abuseIpDbKey) {}
}
use Symfony\Component\DependencyInjection\Attribute\Autowire;
final class AbuseReportCommand
{
public function __construct(
#[Autowire('%abuse_ip_db.api_key%')] private string $abuseIpDbKey
) {}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.