openId : 用户在当前小程序的唯一标识
因为最近根据API调用https://api.weixin.qq.com/sns/jscode2session所以需要配置以下服务,但是官方是不赞成这种做法的,
而且最近把在服务器配置的方法给关闭了。也就是说要获取用户openid,地区等信息只能在后台获取。
那么问题来了,代码怎么实现呢,以下是用java后台的实现
微信客户端的代码实现是这样的
[html] view plain copy print?
wx.login({
success: function (r) {
if (r.code) {
var code = r.code;//登录凭证
if (code) {
//2、调用获取用户信息接口
wx.getUserInfo({
success: function (res) {
//发起网络请求
wx.request({
url: that.data.net + '/decodeUser.json',
header: {
"content-type": "application/x-www-form-urlencoded"
},
method: "POST",
data: {
encryptedData: res.encryptedData,
iv: res.iv,