天天看點

微信内置浏覽器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

繼續閱讀