最近在開發項目,黑坑風雲榜微信小程序時,需要使用到小程序的開放接口,獲取用戶手機號碼。
原來后台系統里面有 easywechat 3.2 的擴展,調用相關解密函數,結果報錯:IV passed is 24 bytes long which is longer than the 16 expected by se。
什么意思呢?
意思是說:給的 sessionKey 是24位的,但解密只需要16位。
如是就多寫一行,截取前16位。
$aesKey= substr($aesKey,0,16);
調試了一下,還是不行。
然后去微信小程序官網下載解密的demo. 加上這行,一運行,OK,解密成功。
{"phoneNumber":"17681849100","purePhoneNumber":"17681849100","countryCode":"86","watermark":{"timestamp":1580825334,"appid":"wx2f0dd38d9ca7a188"}}
demo下載查看地址:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html
注: php版本5.6