System integration AdvertWayCAPTCHA with your website

Inserting AdvertWayCAPTCHA on the page.

On your page, between the form tags (<form></form>) insert the following javascript code. Instead of [your-public-key], insert your site's public key (the change should be made in two places in the code). You will get the public key and the private key after adding your site in the publisher panel.

<script type="text/javascript"
  src="http://api.advertway.pl/get.php?public_key=[your-public-key]"></script>
<noscript>
<iframe src="http://api.advertway.pl/getnoscript.php?public_key=[your-public-key]"
  width="330" height="310" frameborder="0" style="margin: 0"></iframe>
  <div>
    <label>Skopiuj kod captchy:</label>
    <input type="text" name="captcha_challenge_code" />
  </div>
  <div>
    <label>Enter the code from the image:</label>
    <input type="text" name="captcha_solution" />
  </div>
</noscript>

Ajax

If you need to display AdvertWayCAPTCHA dynamically, you can use the AJAX API.

<script type="text/javascript"
  src="http://api.advertway.pl/ajax-get.php"></script>

Then, to create and display the AdvertWayCAPTCHA, just call the 'getAjaxWidget()' method.

awCaptcha.getAjaxWidget('your-public-key', 'div_id');

It is necessary to pass your public key and the parameter 'div_id' to the function. This is the id of the element where you want the AdvertWayCAPTCHA to appear.

Note: Only one instance of AdvertWayCAPTCHA can be displayed on a single page.

Verification

To verify the correctness of the code entered by the user, follow these steps:

  1. Send a POST request to https://api.advertway.com/validate.php with the following parameters:
    • public_key - your site's public key
    • challenge_code - the identifier of AdvertWayCAPTCHA, it is located in the form field named captcha_challenge_code
    • solution - AdvertWayCAPTCHA solution entered by the user, it is located in the form field named captcha_solution
    • user_ip - user's IP address
  2. In response, you will receive information about the verification carried out.
    The answer contains 3 fields, each on a separate line:
    • verification result - can take the value true or false. If the captcha solution is correct it takes the value true, otherwise false.
    • error message - when the result field returned false, the msg field contains a short message describing the cause of the error
    • auth code - contains a code that can be used to verify that this response comes from our servers and is not fake
  3. Optionally, you can verify the answer you receive to be sure that it is true and comes from us.
    . To do this:
    • Combine the values of the form fields captcha_challenge_code, captcha_solution and your site private key into a single string,
    • Then calculate the SHA1 digest for it,
    • so the resulting string compare with the value of the auth field from the response - they should be identical,
    • if the values differ, you should consider the user's captcha solution incorrect

Example code in PHP:

    function verifyResponse($response)
    {
      $privateKey = '[your-private-key]';
      list($rObj->result, $rObj->msg, $rObj->auth) = explode("\n", $response);
      $sha1Hash = sha1($rObj->result . $rObj->msg . $privateKey);
      return $sha1Hash === $rObj->auth ? true : false;
    }
  

Libraries and examples

In order to streamline the process of integrating the AdvertWayCAPTCHA system with your website, you can use a library we have prepared for the PHP language - download

We have also prepared a sample PHP script showing how AdvertWayCAPTCHA works with a simple form on a website - download

Wordpress plugin

If you are using the Wordpress platform, the easiest way to integrate the AdvertWayCAPTCHA system into your site will be to install our plugin - download

This plugin allows you to put AdvertWayCAPTCHA in the registration form and in the comments section. It also supports “Contact Form 7” plugin, which allows you to place captcha in contact form.

Description of the installation:

  1. Download plugin
  2. In the Plugins menu in your wordpress panel, select Upload to server. Enter the location of the zip file with our plugin and upload it to the server. Alternatively, extract the contents of the file and upload the entire “advertwayCaptcha” directory to your Wordpress “/wp-content/plugins/” directory.
  3. Activate the plugin through the “Plugins” menu in Wordpress.
  4. Register for https://publisher.advertway.com, Add your site to the AdvertWayCAPTCHA system. Obtain the keys (public and private), copy and paste them in the AdvertWayCAPTCHA settings form in Wordpress. It is located in the “Settings” menu, where you can also define where the captcha should be placed.

Note: To enable AdvertWayCAPTCHA in “Contact Form 7”, add [awcaptcha awcaptcha-1] above the [submit “Send”] line in the 'Form' field settings.

Plugin for phpBB

If you are running a forum based on phpBB 3, the easiest way to integrate the AdvertWayCAPTCHA system into your forum would be to install our plugin - donwload

Installation:

  1. Pobierz wtyczkę
  2. Extract the contents of the downloaded file.
  3. Follow the instructions in the install3.0.9.xml file

Plugin for IP.Board 3

If you are running a forum based on IP.Board 3, the easiest way to integrate the AdvertWayCAPTCHA system into your forum will be to install our plugin - donwload

Installation:

  1. Download plugin
  2. Extract the contents of the downloaded file.
  3. Follow the instructions in the install.html file
Jak prawie wszystkie strony internetowe również i nasza korzysta z plików cookie. Zapoznaj się z regulaminem, aby dowiedzieć się więcej. Akceptuję