forked from rongcloud/server-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSensitiveExample.java
89 lines (75 loc) · 3.02 KB
/
SensitiveExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package io.rong.example.sensitive;
import io.rong.RongCloud;
import io.rong.methods.sensitive.SensitiveWord;
import io.rong.models.response.ListWordfilterResult;
import io.rong.models.response.ResponseResult;
import io.rong.models.sensitiveword.SensitiveWordModel;
import static org.junit.Assert.assertEquals;
public class SensitiveExample {
/**
* 此处替换成您的appKey
* */
private static final String appKey = "appKey";
/**
* 此处替换成您的appSecret
* */
private static final String appSecret = "appSecret";
/**
* 自定义api地址
* */
private static final String api = "http://api.cn.ronghub.com";
public static void main(String[] args) throws Exception {
RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret);
//自定义 api 地址方式
// RongCloud rongCloud = RongCloud.getInstance(appKey, appSecret,api);
SensitiveWord SensitiveWord = rongCloud.sensitiveword;
/**
*API 文档: http://www.rongcloud.cn/docs/server_sdk_api/sensitive/sensitive.html#add
*
* 添加替换敏感词方法
*
* */
SensitiveWordModel sentiveWord = new SensitiveWordModel()
.setType(0)
.setKeyword("黄赌毒")
.setReplace("***");
ResponseResult addesult = SensitiveWord.add(sentiveWord);
System.out.println("sentiveWord add: " + addesult.toString());
/**
*API 文档: http://www.rongcloud.cn/docs/server_sdk_api/sensitive/sensitive.html#add
*
* 添加替换敏感词方法
*
* */
sentiveWord = new SensitiveWordModel()
.setType(1)
.setKeyword("黄赌毒");
ResponseResult addersult = SensitiveWord.add(sentiveWord);
System.out.println("sentiveWord add replace : " + addersult.toString());
/**
*
* API 文档: http://www.rongcloud.cn/docs/server_sdk_api/sensitive/sensitive.html#getList
* 查询敏感词列表方法
*
* */
ListWordfilterResult result = SensitiveWord.getList(1);
System.out.println("getList: " + result.toString());
/**
*
* API 文档: http://www.rongcloud.cn/docs/server_sdk_api/sensitive/sensitive.html#remove
* 移除敏感词方法(从敏感词列表中,移除某一敏感词。)
*
* */
ResponseResult removeesult = SensitiveWord.remove("money");
System.out.println("SensitivewordDelete: " + removeesult.toString());
/**
*
* API 文档: http://www.rongcloud.cn/docs/server_sdk_api/sensitive/sensitive.html#remove
* 批量移除敏感词方法(从敏感词列表中,批量移除某一敏感词。)
*
* */
String[] words = {"黄赌毒"};
ResponseResult batchDeleteResult = SensitiveWord.batchDelete(words);
System.out.println("SensitivewordbatchDelete: " + batchDeleteResult.toString());
}
}