@@ -27,19 +27,21 @@ You can unpack the archive with the plugin to the root of the site or install it
2727composer require cleantalk/php-antispam
2828```
2929
30- ### Sample SPAM test for text comment and user signup
30+ ### Sample SPAM test for text comment
31+
32+ Notice: You can use the example PHP file from <code >./examples/form_with_handler</code >
3133
3234``` php
3335<?php
3436session_start();
3537
36- $apikey = 'your_cleantalk_api_key ';
38+ $apikey = '';
3739$email_field = 'name_email_form_field';
3840$user_name_field = 'name_user_name_form_field';
3941$message_field = 'name_message_form_field';
4042$type_form = 'contact'; // use 'signup' for user signup form
4143
42- // if downloaded, unzip and include the app:
44+ // if downloaded, unzip and include the app, take your own relative path :
4345require_once 'php-antispam/cleantalk-antispam.php';
4446// if install the app by composer package:
4547use Cleantalk\CleantalkAntispam;
@@ -48,6 +50,19 @@ use Cleantalk\CleantalkAntispam;
4850
4951$cleantalk_antispam = new CleantalkAntispam($apikey, $email_field, $user_name_field, $message_field, $type_form);
5052$api_result = $cleantalk_antispam->handle();
53+ if ($api_result) { // the check fired
54+ if ($api_result->account_status !== 1) {
55+ // something wrong with your key or license, to know why read $api_result->codes
56+ echo 'Allowed. Spam protection disabled.'; // or do nothing
57+ } else {
58+ if ($api_result->allow === 1) {
59+ echo 'Allowed. Spam protection OK.'; // or do nothing
60+ } else {
61+ die('Blocked. Spam protection OK. Reason: ' . $api_result->comment); // or make your own handler
62+ }
63+ }
64+ }
65+ // your further code flow here
5166?>
5267
5368<form method =" post" >
0 commit comments