微信小程序api视频课程-code2Session获取用户唯一的openid的使用
wxml代码
code2Session获取用户唯一的openid
<button bindtap="myopenid">获取用户唯一的openid</button>
js代码
/**
* 页面的初始数据
*/
data: {
},
myopenid:function(){
wx.login({
success(res)
{
console.log(res.code)
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session',
data:{
appid: 'wxc5e0e9e50f9476d3',
secret: '78f4e88fac60687856a08c18727c065a',
js_code: res.code,
grant_type: 'authorization_code'
},
method:"GET",
success:function(res){
//console.log(res.data)
console.log(res.data.openid)
}
})
}
})
},
欢迎大家收看我的****:微信小程序常用API使用
https://edu.****.net/course/detail/16194