1. Go to this page and download the library: Download kaidn/kaidn-php 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/ */
kaidn / kaidn-php example snippets
use Kaidn\Client;
$client = new Client(); // reads KAIDN_API_KEY
$r = $client->score([
'event' => 'signup',
'ip' => $_SERVER['REMOTE_ADDR'],
'email' => $email,
]);
if ($r->isBlocked()) {
throw new Denied($r->reason_text);
}
$r = $client->score([
'event' => 'signup',
'user_id' => $user->id,
'ip' => $_SERVER['REMOTE_ADDR'],
'email' => $_POST['email'],
'device_id' => $_POST['kaidn_device_id'] ?? null, // from @kaidn/fp
]);
$r->verdict; // "allow" | "review" | "block"
$r->reasons; // ["datacenter_ip", "disposable_email"]
$r->reason_text; // a sentence you could send to the customer
$r->score; // 0-100. Bookkeeping, not a probability
if ($r->isBlocked()) {
return deny(); // generic message: a specific one teaches the next attempt
}
if ($r->needsReview()) {
createAccount($holdRewards = true); // they can use the product, they just cannot earn yet
flagForReview($r->event_id, $r->reason_text);
} else {
createAccount();
}
use Kaidn\Client;
use Kaidn\CookieOptions;
$client = new Client(null, ['cookie' => new CookieOptions()]); // off unless you ask
$r = $client->scoreWithCookie(
['event' => 'login', 'ip' => $_SERVER['REMOTE_ADDR'], 'email' => $email],
$_SERVER['HTTP_COOKIE'] ?? null
);
if ($r->set_cookie !== null) {
header('Set-Cookie: ' . $r->set_cookie, false);
}
if ($r->device && $r->device->resolution === 'deterministic') {
// we have seen THIS browser, not something that hashes like it
}
if ($r->identity && User::existsByCanonical($r->identity->email_canonical)) {
return reject('an account already uses this inbox');
}
new Client($apiKey, [
'base_url' => 'https://api.kaidn.io',
'timeout' => 10, // seconds per attempt
'retries' => 2, // extra attempts on a transient failure
'cookie' => new CookieOptions(), // omit to keep cookie handling off
]);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.