| | |
| | | return String.format(format, encrypt, signature, timestamp, nonce); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 提取出 JSON 包中的加密消息(智能机器人) |
| | | * @param jsontext 待提取的json字符串 |
| | | * @return 提取出的加密消息字符串 |
| | | * @throws AesException |
| | | */ |
| | | public static Object[] extractRobot(String jsontext) throws AesException { |
| | | Object[] result = new Object[3]; |
| | | try { |
| | | |
| | | JSONObject json = new JSONObject(jsontext); |
| | | String encrypt_msg = json.getString("encrypt"); |
| | | // System.out.println(json.toString()); |
| | | // String msgid = json.getString("msgid"); |
| | | // String aibotid = json.getString("aibotid"); |
| | | // String chatid = json.getString("chatid"); |
| | | // String chattype = json.getString("chattype"); |
| | | // JSONObject from = json.getJSONObject("from"); |
| | | // String userid = from.getString("userid"); |
| | | // String msgtype = json.getString("msgtype"); |
| | | // JSONObject text = json.getJSONObject("text"); |
| | | // String content = text.getString("content"); |
| | | |
| | | result[0] = encrypt_msg; |
| | | return result; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new AesException(AesException.ParseJsonError); |
| | | } |
| | | } |
| | | } |