This article is an application of WeChat customer service in Enterprise WeChat. The entire logic is: WeChat users send requests, and Enterprise WeChat customer service determines whether the number of people received by the customer service exceeds 20. If it exceeds 20, it enters the waiting process, otherwise it enters the method. respond internally.
Introduce third-party interface---post
The Get type interface also needs to obtain the input parameters of the interface and perform business processing on the return results of the interface.
Get the parameters of the interface
Different from the Post method, the request parameters of the Get method are not JSON type data and can be spliced directly through the .replace() method.
String servicerListUrl = "https://qyapi.weixin.qq.com/cgi-bin/kf/servicer/list?access_token=ACCESS_TOKEN&open_kfid=XXX".replace("ACCESS_TOKEN", sToken.getToken()).replace("XXX", openKfid);
Process the return results of the interface
Because the return result of the interface is JSONObject
So get the size() of servicer_list and make a judgment
JSONObject getServicerListJSONObject = WeixinUtil.HttpRequest(servicerListUrl, "GET", null);
JSONArray getServicerListJSONArray = (JSONArray) getServicerListJSONObject.get("servicer_list");
logger.error("getServicerListJSONArray.size()-----------"+getServicerListJSONArray.size());
if(getServicerListJSONArray.size() < 21){
Map mapText = new HashMap();
mapText.put("content","工作时间内,且接待人员不超过20,会话消息测试---------------");
joSend.put("text",mapText);
}else {
Map mapText = new HashMap();
mapText.put("content","工作时间内,但是接待人员超过20,进入等待---------------");
joSend.put("text",mapText);
}