简介:官方文档中有两种scope:snsapi_base和snsapi_userinfo。其中,snsapi_base是静默授权,不需要用户同意,主要用于获取进入页面的用户的openid。而snsapi_userinfo则用于获取用户的基本信息,需要用户手动同意。
步骤:以下是获取openid的基本步骤
- 在微信中请求https://open.weixin.qq.com/connect/oauth2/authorize?appid={appid}&redirect_uri={redirect_uri}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect,注意填入appid和redirect_uri。