This repository has been archived by the owner on May 2, 2024. It is now read-only.
forked from CleanTalk/php-antispam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.php
55 lines (45 loc) · 1.6 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
//require_once "vendor/autoload.php"; -- Composer
require_once "lib/Cleantalk.php";
require_once "lib/CleantalkRequest.php";
require_once "lib/CleantalkResponse.php";
require_once "lib/CleantalkHelper.php";
require_once "lib/CleantalkAPI.php";
/**
* Cleantalk example
*
* @package Cleantalk Example
* @copyright (C) 2011 - 2012 Сleantalk team (http://cleantalk.ru)
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
* @see http://cleantalk.ru/wiki/doku.php/api
*
*/
use lib\CleantalkRequest;
use lib\Cleantalk;
use lib\CleantalkAPI;
// Take params from config
$config_url = 'http://moderate.cleantalk.ru';
$auth_key = null; // Set Cleantalk auth key
// The facility in which to store the query parameters
$ct_request = new CleantalkRequest();
$ct_request->auth_key = $auth_key;
$ct_request->message = 'stop_word';
$ct_request->sender_email = '[email protected]';
$ct_request->sender_nickname = 'John Dow';
$ct_request->example = str_repeat('Just text ', 10);
$ct_request->agent = 'php-api';
$ct_request->sender_ip = '178.32.183.43';
$ct_request->js_on = 1; # Site visitor has JavaScript
$ct_request->submit_time = 12; # Seconds from start form filling till the form POST
$ct = new Cleantalk();
$ct->server_url = $config_url;
// Check
$ct_result = $ct->isAllowMessage($ct_request);
if ($ct_result->allow == 1) {
echo 'Comment allowed. Reason ' . $ct_result->comment;
} else {
echo 'Comment blocked. Reason ' . $ct_result->comment;
}
echo "<br/>CleantalkAPI call example:<br/>";
var_dump(CleantalkAPI::method__notice_validate_key('',''));
?>