微信小程序之微信鑑權

轉載:https://blog.csdn.net/qq_20094173/article/details/79671280

一、通過微信接口頻繁獲取用戶信息

    1.請求https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_base&state=1#wechat_redirect,設置回調地址替換佔位符REDIRECT_URI;

    2.微信回調REDIRECT_URI時,將攜帶code參數,通過該參數再向微信獲取用戶信息,接口:https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code;

        3.通過第2步,即可獲取用戶基本信息,如openid等;

二、所有接口請求應用接口

    1.應用接口再請求https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_base&state=1#wechat_redirect,並設置回調地址替換佔位符REDIRECT_URI;

        2.微信回調後重復一.2步

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章