/// <summary>
 /// 执行获取微信用户OpenId的请求
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="model"></param>
 /// <returns></returns>
 public T Execute<T>(WeChatModel Model)
 {
     GetOpenIdByPageAuthorizeModel model = Model as GetOpenIdByPageAuthorizeModel;
     sRequestUrl = string.Format(sRequestUrl, model.sAppId, model.sAppSecret, model.sCode);
     string result = HttpHelper.HttpGet(sRequestUrl);
     T respone = JsonHelper.Deserialize<T>(result);
     return respone; 
 }
Esempio n. 2
0
        /// <summary>
        /// 执行通过网页授权获取微信用户信息的请求
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="model"></param>
        /// <returns></returns>
        public T Execute <T>(WeChatModel Model)
        {
            GetWeChatUserInfoByPageAuthorizeModel model = Model as GetWeChatUserInfoByPageAuthorizeModel;
            //第一步 获取openid和access_token
            IWeChatRequest request            = new GetOpenIdByPageAuthorizeRequest();
            GetOpenIdByPageAuthorizeModel obj = new GetOpenIdByPageAuthorizeModel()
            {
                sAppId = model.sAppId, sAppSecret = model.sAppSecret, sCode = model.sCode
            };
            GetOpenIdByPageAuthorizeRespone res = request.Execute <GetOpenIdByPageAuthorizeRespone>(obj);

            //第二步 拉取用户信息
            sRequestUrl = string.Format(sRequestUrl, res.access_token, res.openid);
            string result  = HttpHelper.HttpGet(sRequestUrl);
            T      respone = JsonHelper.Deserialize <T>(result);

            return(respone);
        }