前言:
先申明一下本人纯萌新JDBC没学明白 前段时间一直想好好利用neko002大佬分享在论坛的词库
链接文本但苦于没有衣来伸手饭来张口的插件,于是想着利用论坛的自定义API插件实现,结果发现没有可以白嫖的api,于是拿出与我家猫猫争夺我肩膀的所有权的勇气花了一下午查资料解决了api,但是由于我能力太差实在是没有实现API自定义插件用我自己的API哪位大佬成功了能不能白嫖一下配置。
但是本人mysql又只会增删改查,导致API的返回值只要匹配就一股脑返回,由于实在是写不来随机用相似的一条返回于是决定摆烂,相信有大佬能用插件解决或者友情提供几句mysql语句解决这个问题。
闲聊或者提供帮助及建议请移步群467021837
链接文本
下面是API说明文档及调用示例
API接口文档
可爱系二次元bot词库1.5万词V1.2
闲聊群:467021837
接口地址:
http://www.shenyuge.top:8520/api/keai/
接口备注:可爱系二次元bot词库1.5万词V1.2
Content-Type:application/x-www-form-urlencoded
请求参数:
参数名称
参数类型
参数说明
text
string
提问
傲娇系二次元bot词库5千词V1.2
接口地址:
http://www.shenyuge.top:8520/api/aojiao/
接口备注:傲娇系二次元bot词库5千词V1.2
Content-Type:application/x-www-form-urlencoded
请求参数:
参数名称
参数类型
参数说明
text
string
提问
调用示例
shell
curl -H 'Content-Type: application/x-www-form-urlencoded' -X POST --data-urlencode text="你好" 'http://www.shenyuge.top:8520/api/aojiao/'
javascript
// npm install axios
// npm install qs
const axios = require('axios');
const qs = require('qs');
const data = qs.stringify({
text: "你好"
}, { indices: false })
axios({
method: 'post',
url: 'http://www.shenyuge.top:8520/api/aojiao/',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: data,
}).then(response => {
console.log(response.data);
}).catch(error => {
console.log(error);
});
python
import requests
from urllib import parse
requestUrl = 'http://www.shenyuge.top:8520/api/aojiao/'
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
formData = {
"text": "你好"
}
data = parse.urlencode(formData, True)
response = requests.post(requestUrl, headers = headers, data = data)
print(response.status_code)
print(response.text)
go
package main
import (
"fmt"
// go get -u github.com/imroc/req/v3
"github.com/imroc/req/v3"
"log"
"net/url"
)
func main() {
requestUrl := "http://www.shenyuge.top:8520/api/aojiao/"
client := req.C()
data := url.Values{}
data.Set("text", "你好")
bodyString := data.Encode()
resp, err := client.R().
SetHeader("Content-Type", "application/x-www-form-urlencoded").
SetBodyString(bodyString).
Post(requestUrl)
if err != nil {
log.Fatal(err)
}
if !resp.IsSuccess() {
fmt.Println("bad response status:", resp.Status)
return
}
fmt.Println(resp.String())
}
java
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) throws IOException {
String requestUrl ="http://www.shenyuge.top:8520/api/aojiao/";
URL url = new URL(requestUrl);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.connect();
HashMap<String, Object> params = new HashMap<>();
params.put("text", "你好");
StringBuilder result = new StringBuilder();
boolean first = true;
for(Map.Entry<String, Object> entry : params.entrySet()){
if (first){
first = false;
} else {
result.append("&");
}
String key = entry.getKey();
Object value = entry.getValue();
if(value instanceof List){
List<String> list = (List<String>)value;
String collectResult = list.stream().map(s -> {
try {
return URLEncoder.encode(key, "UTF-8") + "=" + URLEncoder.encode(s, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
}).filter(Objects::nonNull).collect(Collectors.joining("&"));
result.append(collectResult);
}else if(value instanceof String){
result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
result.append("=");
result.append(URLEncoder.encode((String) entry.getValue(), "UTF-8"));
}
}
String dataStr = result.toString();
OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream(),"UTF-8");
writer.write(dataStr);
writer.flush();
writer.close();
InputStream is = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuffer stringBuffer = new StringBuffer();
String strRead;
while ((strRead = reader.readLine()) != null) {
stringBuffer.append(strRead);
stringBuffer.append("\r\n");
}
reader.close();
connection.disconnect();
System.out.println(stringBuffer);
}
}
[啊吧啊吧]7427971a-233f-4629-97dc-563854692c04-image.png