PHP code example of zenghuang19 / sensitive-words
1. Go to this page and download the library: Download zenghuang19/sensitive-words 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/ */
zenghuang19 / sensitive-words example snippets
$filename = './words.txt';
$sensitive = new \Codetrainee\SensitiveWords\SensitiveWord();
$sensitive->addWords($filename);
$txt = "鸡鸡";
$words = $sensitive->filter($txt);//敏感词替换
$word = $sensitive->detection($txt);//敏感词检测
var_dump($words, $word);
$APP_ID = '百度AppID';
$API_KEY = 'API Key';
$SECRET_KEY = 'Secret Key';
$client = new AipImageCensor($APP_ID, $API_KEY, $SECRET_KEY);
$result = $client->textCensorUserDefined("测试文本");
dd($result);
if ($result['conclusionType'] != 1){
//不合格的返回代码
}