微信小程序登录,服务端解密有几率-41003

服务器是将unionId作为唯一id的,需要使用WXBizDataCrypt.decryptData将encryptedData解密出来。不过在调用WXBizDataCrypt.decryptData的时候总是会有30%的几率解密失败,返回errorCode -41003

服务器端语言:PHP

原因:

每次小程序获取到iv的值中间有空格的,就会出错

js传输 iv 的时候用 encodeURIComponent 函数进行 urlencode (空格其实是符号:+ ?),PHP端接收的时候 urldecode 就可以了

猜你喜欢

转载自blog.csdn.net/sun124608666/article/details/80616499