public H5UserInfo GetH5UserInfo(string code) { H5UserInfo h5UserInfo = null; WebClient client = new WebClient(); string tokenResult = client.DownloadString($"https://mpx.wetalk.im/sns/oauth2/access_token?appid=wxc1a7dbfa678d92ce&secret=rmgMs5fnuoRBJ3YyZexNV2w00huW0M&code={ code }&grant_type=authorization_code"); if (!string.IsNullOrEmpty(tokenResult)) { H5Token token = JsonConvert.DeserializeObject <H5Token>(tokenResult); string h5UserInfoResult = client.DownloadString($"https://mpx.wetalk.im/sns/userinfo?access_token={ token.access_token }&openid={ token.openid }&lang=zh_CN"); if (!string.IsNullOrEmpty(h5UserInfoResult)) { h5UserInfo = JsonConvert.DeserializeObject <H5UserInfo>(h5UserInfoResult); } } return(h5UserInfo); }
public ResultBase GetH5UserInfo(string code) { ActivityInfoService activityInfoService = new ActivityInfoService(); H5UserInfo resq = null; try { resq = activityInfoService.GetH5UserInfo(code); } catch (Exception ex) { return(new ResultBase { IsSuccess = false, Code = CodeConstant.ServerError, Message = ex.Message + ex.StackTrace }); } if (resq != null && !string.IsNullOrEmpty(resq.openid)) { return(new ResultBase { IsSuccess = true, Code = CodeConstant.Success, Data = resq }); } else { return(new ResultBase { IsSuccess = false, Code = CodeConstant.DataNull }); } }