获取openId流程图

这里写图片描述

url2,用户授权获取code,这个code会跟在redirect_uri=url1后面,有用户发送到业务系统,业务系统拿到code后,可以获取用户openId.
https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect

url3,拿到code后,像微信服务器发送请求,可以获取openId和access_token
https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code

拿到openId和access_token后可以获取用户的详细信息
https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN

你可能感兴趣的:(微信公众号开发)