1. Go to this page and download the library: Download isapp/ai-spamdetector library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
isapp / ai-spamdetector example snippets
use Isapp\AiSpamdetector\Client;use Isapp\AiSpamdetector\FormData;use Isapp\AiSpamdetector\SpamDetector;
$client = new Client(apiKey: getenv('OPENAI_API_KEY'), organization: getenv('OPENAI_ORGANIZATION'),model: 'gpt-4');
$detector = new SpamDetector(client: $client);
$form = new FormData(
name: 'James Bond',
email: '[email protected]',
message: 'Click here for FREE cash!!!',
userAgent: $_SERVER['HTTP_USER_AGENT'] ?? null,
);
$isNotSpam = $detector->analyze($form); // returns true if message is not spam