dev_该合并了 #8
@ -60,8 +60,12 @@ public class BaiduGPTManager {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("messages", messages);
|
||||
System.out.println("json = " + json);
|
||||
String post = HttpTools.post(url + "?access_token=" + getToken()
|
||||
, json.toJSONString().getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("Content-Type", "application/json");
|
||||
map.put("Content-Length", String.valueOf(json.toJSONString().getBytes(StandardCharsets.UTF_8).length));
|
||||
String post = HttpTools.http_post(url + "?access_token=" + getToken()
|
||||
, json.toJSONString().getBytes(StandardCharsets.UTF_8),0,map);
|
||||
System.out.println("post = " + post);
|
||||
if (StringUtils.isEmpty(post)) {
|
||||
clear();
|
||||
|
@ -119,10 +119,10 @@ public class HttpTools {
|
||||
reader.close();
|
||||
return finalStr;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
if (index < HttpRequestIndex) {
|
||||
return http_post(url, body, index + 1, headers);
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -153,6 +153,7 @@ public class HttpTools {
|
||||
string = new StringBuilder(string.substring(1, string.length()).replaceAll(" ", ""));
|
||||
return string.toString();
|
||||
}
|
||||
|
||||
public static String toUrlParams(Map<String, String> map) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String key : map.keySet()) {
|
||||
|
Loading…
Reference in New Issue
Block a user