Example #1
0
        /// <summary>
        /// 个人微信号授权回调方法
        /// </summary>
        /// <param name="code"></param>
        /// <param name="state"></param>
        /// <param name="appid"></param>
        /// <returns></returns>
        public string AuthCallback(string code, string state, string appid)
        {
            //通过,用code换取access_token
            var result = ProxyOAuthApi.GetOpenAccessToken(appid, code, WXSDK.Config.ServerAppID, WeixinInfo.component_tokenInfo);

            if (result.errcode != ReturnCode.请求成功)
            {
                return("错误:" + result.errmsg);
            }

            if (result.scope == OAuthScope.snsapi_userinfo.ToString())//获取用户信息
            {
                var userInfo = ProxyOAuthApi.GetUserInfo(result.access_token, result.openid);
                //todo:保存用户信息
            }
            return(GetParemeter(state, "openid=" + result.openid + "&authorizer_appid=" + appid));
        }
Example #2
0
        /// <summary>
        /// 个人微信号授权
        /// </summary>
        /// <param name="appid">appid</param>
        /// <param name="state">授权后跳转RUL</param>
        /// <param name="scope">是否显示授权信息</param>
        /// <returns></returns>
        public string UtilityAuth(string authorizer_appid, string state, bool isShow)
        {
            string url = ProxyOAuthApi.GetAuthorizeUrl(authorizer_appid, WXSDK.Config.AuthRedirectUri, isShow ? OAuthScope.snsapi_userinfo : OAuthScope.snsapi_base, state, WXSDK.Config.ServerAppID);

            return(url);
        }