Skip to content

违禁词检测接口文档 检测中...

接口地址: https://api.chyt.top/check_prohibited_words

请求方式: POST

返回格式: JSON

请求示例: https://api.chyt.top/check_prohibited_words?msg=你好

接口说明: 检查输入的文本中是否包含违禁词,并返回检测到的违禁词列表。

请求参数

参数名必选类型说明
msgstring需要检测的文本内容

返回参数

参数名类型说明
codeint请求状态码,200 表示成功,其他值表示失败
msgstring返回信息
numint检测到的违禁词数量
dataarray违禁词列表,包含检测到的违禁词

返回示例

成功响应:

json
{
  "code": 200,
  "msg": "成功",
  "num": 2,
  "data": ["违禁词1", "违禁词2"]
}

代码示例

php
<?php
$url = 'https://api.chyt.top/check_prohibited_words';
$data = ['msg' => '测试内容'];

$options = [
    'http' => [
        'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
        'method' => 'POST',
        'content' => http_build_query($data),
    ]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
echo $response;
?>
python
import requests

url = 'https://api.chyt.top/check_prohibited_words'
data = {'msg': '测试内容'}

response = requests.post(url, data=data)
print(response.json())
JavaScript
const https = require('https');
const querystring = require('querystring');

const data = querystring.stringify({ msg: '测试内容' });
const options = {
    hostname: 'api.chyt.top',
    path: '/check_prohibited_words',
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Content-Length': data.length
    }
};

const req = https.request(options, res => {
    res.on('data', d => process.stdout.write(d));
});
req.write(data);
req.end();
java
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static void main(String[] args) throws IOException {
        URL url = new URL("https://api.chyt.top/check_prohibited_words");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        conn.setDoOutput(true);

        String data = "msg=测试内容";
        try (OutputStream os = conn.getOutputStream()) {
            os.write(data.getBytes());
        }

        try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
            String response;
            while ((response = br.readLine()) != null) {
                System.out.println(response);
            }
        }
    }
}
C
#include <stdio.h>
#include <curl/curl.h>

int main() {
    CURL *curl = curl_easy_init();
    if(curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://api.chyt.top/check_prohibited_words");
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "msg=测试内容");

        CURLcode res = curl_easy_perform(curl);
        if(res != CURLE_OK)
            fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));

        curl_easy_cleanup(curl);
    }
    return 0;
}