|
@@ -25,6 +25,7 @@ public class WxArticleDeleteService {
|
|
|
.build();
|
|
|
|
|
|
}
|
|
|
+
|
|
|
public RequestResult<String> deleteArticle(String token, String msgId, int index) {
|
|
|
RequestResult<String> result = new RequestResult<>();
|
|
|
JSONObject jsonBody = new JSONObject();
|
|
@@ -46,9 +47,13 @@ public class WxArticleDeleteService {
|
|
|
log.info("wx delete api responseContent = {}", responseContent);
|
|
|
if (response.isSuccessful()) {
|
|
|
JSONObject obj = JSONObject.parseObject(responseContent);
|
|
|
- if (Objects.nonNull(obj) && obj.containsKey("errcode") && obj.getInteger("errcode") == 0) {
|
|
|
- result.setSuccess(true);
|
|
|
- result.setResponse(obj.toJSONString());
|
|
|
+ if (Objects.nonNull(obj) && obj.containsKey("errcode")) {
|
|
|
+ if (obj.getInteger("errcode") == 0) {
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResponse(obj.toJSONString());
|
|
|
+ } else {
|
|
|
+ result.setFailReason(obj.getString("errmsg"));
|
|
|
+ }
|
|
|
} else {
|
|
|
result.setFailReason("response empty");
|
|
|
}
|
|
@@ -63,4 +68,46 @@ public class WxArticleDeleteService {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ public RequestResult<String> clearQuota(String token, String appid) {
|
|
|
+ RequestResult<String> result = new RequestResult<>();
|
|
|
+ JSONObject jsonBody = new JSONObject();
|
|
|
+ jsonBody.put("appid", appid);
|
|
|
+ try {
|
|
|
+ MediaType mediaType = MediaType.parse("application/json");
|
|
|
+ RequestBody body = RequestBody.create(mediaType, JSONObject.toJSONString(jsonBody));
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url("https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=" + token)
|
|
|
+ .method("POST", body)
|
|
|
+ .addHeader("Content-Type", "application/json")
|
|
|
+ .addHeader("Authorization", "Bearer sk-5DqYCa88kche6nwIWjLE1p4oMm8nXrR9kQMKbBolNAWERu7q")
|
|
|
+ .build();
|
|
|
+ Response response = client.newCall(request).execute();
|
|
|
+
|
|
|
+ String responseContent = response.body().string();
|
|
|
+ result.setResponseStr(responseContent);
|
|
|
+ log.info("wx clearQuota api responseContent = {}", responseContent);
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ JSONObject obj = JSONObject.parseObject(responseContent);
|
|
|
+ if (Objects.nonNull(obj) && obj.containsKey("errcode")) {
|
|
|
+ if (obj.getInteger("errcode") == 0) {
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResponse(obj.toJSONString());
|
|
|
+ } else {
|
|
|
+ result.setFailReason(obj.getString("errmsg"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.setFailReason("response empty");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ JSONObject json = JSONObject.parseObject(responseContent);
|
|
|
+ result.setFailReason("request error code:" + response.code() + " message:" + json.getString("error"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("wx clearQuota api error", e);
|
|
|
+ result.setSuccess(false);
|
|
|
+ result.setFailReason("request error" + e.getMessage());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|