公众号开发-获取用户信息

微信公众平台:https://mp.weixin.qq.com

内部测试的appid REDIRECT_URI(用户登录链接地址) SECRET秘钥
APPID = ed
REDIRECT_URI = ed
SCOPE = ed
SECRET = ed


1.获取用户code数据 (文档中有此链接)
https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
(APPID、REDIRECT_URI 、SCOPE )
获得CODE = 0618RgVf17UNcz0h1pXf1PVbVf18RgVR


2.获取用户refresh_token
https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
(SECRET 、CODE)

3.再次获取用户access_token openid
https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN
(appid、refresh_token)


4.获取用户信息
https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
(access_token、openid)

猜你喜欢

转载自www.cnblogs.com/Jessical8619/p/9913791.html
今日推荐