主要是要做好私钥公钥,
然后公钥保存在企业微信后台
私钥保存在解密的程序中,
然后进行二次解密就可以了
int seq = Integer.parseInt(args[1]);
int limit = Integer.parseInt(args[2]);
long slice = Finance.NewSlice();
ret = Finance.GetChatData(sdk, seq, limit, args[3], args[4], Integer.parseInt(args[5]), slice);
if (ret != 0) {
System.out.println("getchatdata ret " + ret);
return;
}
String text = Finance.GetContentFromSlice(slice);
System.out.println(“getchatdata :”+ text);
WechatResponse res = (WechatResponse)JSON.parseObject(text, WechatResponse.class);
if(res.getErrcode().equals(“0”)){
List chatdataList = res.getChatdata();
int maxNum = chatdataList.size();
for (int i = 0; i < maxNum; i++) {
JSONObject chatdataitem = (JSONObject)chatdataList.get(i);
System.out.println(“seq :”+ chatdataitem.get(“seq”)+" msgid:"+chatdataitem.get(“msgid”));
String encrypt_random_key = chatdataitem.getString(“encrypt_random_key”);
String publickey_ver = chatdataitem.getString(“publickey_ver”);
String priKey = getPrivaKey(publickey_ver);
String key = getDecriptKey(encrypt_random_key,priKey);
long msg = Finance.NewSlice();
int ret1 = Finance.DecryptData(sdk,key,chatdataitem.getString(“encrypt_chat_msg”), msg);
String content = Finance.GetContentFromSlice(msg);
System.out.println("decrypt ret:" + ret1 + " msg:" + content);
JSONObject chatmsg = JSON.parseObject(content);
System.out.println("action:" + chatmsg.getString("action") + " msgtype:" + chatmsg.getString("msgtype"));
Finance.FreeSlice(msg);
}
}
通过开发,已经可以商用了,服务了好几个客户了
实现了多线程秒拉取机制
实现了可视化分级授权管理。
截图如下