Using the Service Without the CleanTalk PHP Library

 

Direct calls to the servers:

GET query:

You could use this for debugging. Each parameter sends as GET parameter.

https://api.cleantalk.org/?method_name=spam_check&auth_key=123456&email=stop_email@example.com&ip=127.0.0.1

You will get a JSON string. See below.

wget query:

wget -O- --post-data='
{"method_name":"check_newuser","auth_key":"your_acccess_key","sender_email":"stop_email@example.com","sender_nickname":"John
Doe","sender_ip":"127.0.0.1","js_on":1,"submit_time":15}' https://moderate.cleantalk.org/api2.0

submit_time и js_on must be 12 and 1.

 

Our API:

PHP part:

<?php
session_start();
if (count($_POST))
{
        $sender_info = array(
                'user_agent' => $_SERVER['HTTP_USER_AGENT'],
                'referer' => $_SERVER['HTTP_REFERER'],
        );
        $js_on = 0;
        if (isset($_POST['js_on']) && $_POST['js_on'] == date("Y")) //comparing dates from browser and server - it should be equal if JavaScript is enabled
                $js_on = 1;
        $params = array(
                'method_name' => 'check_newuser',
                'auth_key' => 'enter_your_key',
                'sender_email' => isset($_POST['email']) ? $_POST['email'] : 'stop_email@example.com',
                'sender_nickname' => isset($_POST['login']) ? $_POST['login'] : 'John Doe',
                'sender_ip' => $_SERVER['REMOTE_ADDR'],
                'js_on' => $js_on ,
                'submit_time' => time() - (int) $_SESSION['ct_submit_time'], //"submitting time" minus "accessing time" = submit_time
                'sender_info' => json_encode($sender_info),
        );
        $check = curl_init();
        curl_setopt($check, CURLOPT_URL, 'https://moderate.cleantalk.org/api2.0');
        curl_setopt($check, CURLOPT_TIMEOUT, 10);
        curl_setopt($check, CURLOPT_POST, true);
        curl_setopt($check, CURLOPT_POSTFIELDS, json_encode($params)); // receive server response ...
        curl_setopt($check, CURLOPT_RETURNTRANSFER, true); // resolve 'Expect: 100-continue' issue
        curl_setopt($check, CURLOPT_HTTPHEADER, array('Expect:'));
        curl_setopt($check, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($check, CURLOPT_SSL_VERIFYHOST, false);
        $result = curl_exec($check);
        curl_close($check);
 
        if ($result)
        {
                $ct_result = json_decode($result);
                if ($ct_result->allow == 1)
                        echo 'Message allowed. Reason ' . $ct_result->comment;
                else
                        echo 'Message forbidden. Reason ' . $ct_result->comment;
                echo '<br /><br />';
        }
else
        $_SESSION['ct_submit_time'] = time(); //save page accessing time when access page via GET method
}
?>

Submit_time and js_on parameters are very important for checking. Submit_time is the difference between submitting form time and page accessing time. Js_on can be calculated by evaluating some JavaScript code in browser and comparing with reference value on server side.  See in example, how you can calculate them:

 

HTML part:

<form method="post">
        <label for="login">Login:<label>
        <input type="text" name="login" id="login" /> <br />
        <label for="email">Email:<label>
        <input type="text" name="email" id="email" value="" /> <br />
        <input type="hidden" name="js_on" id="js_on" value="0" />
        <input type="submit" />
</form>
<script type="text/javascript">
var date = new Date(); document.getElementById("js_on").value = date.getFullYear();
</script>

 

In all variants you will get a JSON string as a response, for example:

In case of using without the API you have to parse that string yourself.

{
"stop_queue" : 1,
"inactive" : 0,
"version" : "7.76",
"codes" : "DENIED BL FAST_SUBMIT",
"spam" : 0,
"js_disabled" : 0,
"comment" : "*** Forbidden. Sender blacklisted. You submitted too quickly. You may try again in a few seconds. ***",
"blacklisted" : 1,
"fast_submit" : 1,
"account_status" : "1",
"id" : "5a78dca12150a9bb3364a69ee02879a9",
"allow" : 0
}

 

Response explanation:

  • stop_queue - (0) or (1);
  • inactive - account state (0) or (1);
  • version - version of server program;
  • codes - response codes;
  • spam - seems like spam (0) or (1);
  • js_disabled - JavaScript is disabled (0) or (1);
  • comment - server's comment (see below)
  • blacklisted - sender is blacklisted (0) or (1);
  • fast_submit - check of the submitting speed  (0) or (1);
  • account_status - account status (0) or (1)
  • id - id of request (useful for tech support);
  • allow - result: allowed (1) or not (0).

 

Codes explanation:

  • allow - is registration allowed (1) or not (0);
  • comment - comment for server's decision or for another errors (wrong access key etc.);
  • id - message ID (helpful for our support),
  • codes - answer codes.
  • Answer codes may be:
  • 'ALLOWED' - Allowed.
  • 'ALLOWED_PRIV_LIST' - Private list allow.
  • 'ALLOWED_PROFILE' - Profile allowed.
  • 'ALLOWED_USER' - User allowed.
  • 'BAD_INSTALL' - Check plugin setup.
  • 'BAD_LANGUAGE' - Contains bad language.
  • 'BL_DOMAIN' - HTTP links blacklisted
  • 'BL' - Sender blacklisted.
  • 'COMMENT_TYPE_UNKNOWN' - Trackback, Pingback comment's type need manual moderation.
  • 'CONTACTS' - Contains links.
  • 'CONTACTS_DATA' - Contains contacts.
  • 'DENIED' - Forbidden.
  • 'DENIED_GREY_LIST' - Please submit form again.
  • 'DENIED_PRIV_LIST' - Private list deny.
  • 'DENIED_PROFILE' - Profile forbidden.
  • 'DENIED_USER' - User forbidden.
  • 'ERR_CLIENT_IP_EQ_SERVER_IP' - Site visitor IP is equal to server site IP.
  • 'FAST_SUBMIT' - Submitted too quickly.
  • 'FORBIDDEN' - Forbidden.
  • 'JS_DISABLED' - Please enable JavaScript.
  • 'KEY_NOT_FOUND' - “Anti-Spam disabled. Check Access key.
  • 'MANUAL' - Need manually approve.
  • 'MULT_MESSAGE' - Massive posting.
  • 'MULT_SUBMIT' - Multiple comments submit.
  • 'NO_NORM_WORDS' - Without dictionary words.
  • 'OFFTOP' - Off-topic.
  • 'SERVICE_DISABLED' - Service disabled. Check account status.
  • 'SERVICE_FREEZED' - Service froze. Please extend the limit.
  • 'STOP_LIST' - Contains stop words.
  • 'TRIAL_EXPIRED' - Trial period expired.
  • 'USERNAME_SPAM' - Spam sender name.
  • 'WRONG_TZ' - Wrong time zone.
  • 'EMAIL_NOT_EXISTS' - E-mail address does not exist.
  • 'BL_EMAIL' - E-mail blacklisted
  • 'BL_IP' - IP address blacklisted
  • 'SEEMS_SPAM_EMAIL' -  E-mail contains spam templates
  • 'SEEMS_SPAM_HEADERS' - HTTP-request headers look like spam bot
  • 'SEEMS_SPAM_MESSAGE' - Message contains spam templates
  • 'SEEMS_SPAM_NICK' - Nickname contains spam templates
  • 'EMAIL_DOMAIN_NOT_EXISTS'- E-mail domain does not exist.

 

There are two codes with the same meaning ’DENIED’ and ’FORBIDDEN’. It is made so to support old versions of the CleanTalk plugin.

 

 

If you haven't found the answer to your question, please, contact our support team:

https://cleantalk.org/my/support/open

 

 

Was this information helpful?

No

Yes




Perhaps it would also be interesting