PHP integration guide
Add spam detection to any PHP application. No library required — plain HTTP with file_get_contents, Guzzle, or the Symfony HTTP client.
Authentication: All requests need a Bearer token in the
Authorization header. Generate one in Settings → API Tokens.
Native PHP — file_get_contents
No dependencies. Works on any PHP 7.4+ installation.
function checkSpam(string $type, string $content, string $ip = ''): array {
$response = file_get_contents(
'https://kireifilter.net/api/v1/spam-check',
false,
stream_context_create(['http' => [
'method' => 'POST',
'header' => "Authorization: Bearer " . YOUR_TOKEN . "\r\nContent-Type: application/json",
'content' => json_encode([
'type' => $type,
'content' => $content,
'metadata' => ['ip' => $ip],
]),
]])
);
return json_decode($response, true);
}
// Usage
$result = checkSpam('comment', $_POST['message'], $_SERVER['REMOTE_ADDR']);
if ($result['isSpam']) { http_response_code(422); exit; }
Guzzle
For projects already using Guzzle or the Symfony HTTP client.
$client = new GuzzleHttp\Client();
$res = $client->post('https://kireifilter.net/api/v1/spam-check', [
'headers' => ['Authorization' => 'Bearer ' . YOUR_TOKEN],
'json' => ['type' => 'comment', 'content' => $content, 'metadata' => ['ip' => $ip]],
]);
$result = json_decode($res->getBody(), true);
Response fields
| Field | Type | Description |
|---|---|---|
| isSpam | boolean | true if score ≥ 0.5 |
| score | float | 0.0 (clean) to 1.0 (spam). Threshold is 0.5. |
| reasons | string[] | Detection signals that contributed to the score |