天天看点

微信内置浏览器H5自动登录获取用户信息

首先公众号授权。

然后拿到公众号内的APP_ID

然后对自己服务器的域名进行授权

然后调用code接口获取用户的code码: https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0e81c3bee622d60&redirect_uri=自己的域名 &response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect

然后用code码和公众号里的appsecret获取access_token和openid https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code

再用access_token和openid去获取用户信息 https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN

继续阅读