Skip to content

wolfsoft/botguard-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BotGuard PHP API Connector

Latest Stable Version Build Status codecov License

An integration library for BotGuard Cloud.

use BotGuard\BotGuard;
use BotGuard\Profile;

// Initialize BotGuard Service instance
$botguard = BotGuard::instance([
	'server' => 'xxx.botguard.net',
	'backup' => 'yyy.botguard.net',
]);

// Check incoming request
$profile = $botguard->check();

// Do bot mitigation
if ($profile) {
	switch ($profile->getMitigation()) {
		case Profile::MITIGATION_DENY:
		case Profile::MITIGATION_RETURN_FAKE:
			http_response_code(403);
			exit;
		case Profile::MITIGATION_CHALLENGE:
			http_response_code(403);
			$profile->challenge();
			exit;
		case Profile::MITIGATION_REDIRECT:
		case Profile::MITIGATION_CAPTCHA:
			header('Location: ' . $profile->getMitigationURL(), true, 302);
			exit;
	}
}

echo 'Welcome, human';

Installation

With Composer

$ composer require wolfsoft/botguard-php
{
    "require": {
        "wolfsoft/botguard-php": "^1.1"
    }
}
<?php
require 'vendor/autoload.php';

use BotGuard\BotGuard;
use BotGuard\Profile;

// the rest of the code

Without Composer

Why are you not using Composer? Download BotGuard.php from the repo and save the file into your project path somewhere.

<?php
require 'path/to/Profile.php';
require 'path/to/BotGuard.php';

use BotGuard\BotGuard;
use BotGuard\Profile;

// the rest of the code

Documentation

Integration Guide

About

BotGuard PHP API Connector

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages