MCPcopy Create free account
hub / github.com/Devo919/Gewechat / postJSON

Method postJSON

src/main/java/util/OkhttpUtil.java:67–88  ·  view source on GitHub ↗
(String route,JSONObject param)

Source from the content-addressed store, hash-verified

65 }
66
67 public static JSONObject postJSON(String route,JSONObject param){
68 Map<String,Object> header = new HashMap<>();
69 if(token != null){
70 header.put("X-GEWE-TOKEN",token);
71 }
72 try {
73 if(baseUrl == null || "".equals(baseUrl)){
74 throw new RuntimeException("baseUrl 未配置");
75 }
76 String res = json(baseUrl + route, header, param.toJSONString(), okHttpClient());
77 System.out.println(res);
78 JSONObject jsonObject = JSONObject.parse(res);
79 if(jsonObject.getInteger("ret") == 200){
80 return jsonObject;
81 }else{
82 throw new RuntimeException(res);
83 }
84 } catch (Exception e) {
85 System.out.println("url="+baseUrl + route);
86 throw new RuntimeException(e);
87 }
88 }
89
90 private static String json(String url, Map<String, Object> header, String json, OkHttpClient client) throws IOException {
91 // 创建一个请求 Builder

Callers 15

syncMethod · 0.95
getContentMethod · 0.95
deleteMethod · 0.95
aMethod · 0.95
fetchContactsListMethod · 0.95
getBriefInfoMethod · 0.95
getDetailInfoMethod · 0.95
searchMethod · 0.95
deleteFriendMethod · 0.95
setFriendPermissionsMethod · 0.95
setFriendRemarkMethod · 0.95
getPhoneAddressListMethod · 0.95

Calls 2

jsonMethod · 0.95
okHttpClientMethod · 0.95

Tested by

no test coverage detected