JFinal Weixin 1.1 主要添加了消息加密功能,以及对 access token 意外失效问题做出了处理。
access token 通常会因为外部原因而意外失效:
1:项目中 AccessTokenApi 在获取到 access token 之后,在微信公众平台利用在线调试工具再次获取了该公众号的 access token
2:项目中 AccessTokenApi 在获取到 access token 之后,其它程序包括正在开发中的程序再次获取了该公众号的 access token
3:微信服务器未知原因导致当前 access token 失效(测试证实概率较高)
开启加密功能步骤如下:
1:在配置文件中添加
encryptMessage=true
encodingAesKey=yourEncodingAesKey
2:在 YourJFinalConfig.configConstant(Constants me) 中添加
ApiConfig.setEncryptMessage(getPropertyToBoolean("encryptMessage", false));
ApiConfig.setEncodingAesKey(getProperty("encodingAesKey"));
3:登录微信平台配置 EncodingAESKey 值,以及选择消息加解密方式为安全模式,如下图所示
4:出现java.security.InvalidKeyException:illegal Key Size异常是正常现象,按照微信官方给的方案来解决:http://mp.weixin.qq.com/wiki/index.php?title=%E5%BC%80%E5%8F%91%E8%80%85FAQ
具体用法参考 jfinal-weixin-1.9-demo,在此下载 http://www.jfinal.com
下载地址:http://www.jfinal.com/download?file=jfinal-weixin-1.1-bin-with-src.jar
来自:开源中国社区

