/// <summary> /// 通过openid 获取用的基本信息 /// </summary> /// <param name="Openid"></param> /// <returns></returns> public WeChatUser GetUserInfoOpenid(string AppId, string Openid) { WeChatUser UModel = new WeChatUser(); Senparc.Weixin.MP.Entities.WeixinUserInfoResult Model = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(WeChatDeploy.GetAccessToken(AppId), Openid); UModel.HeadImgUrl = Model.headimgurl ?? ""; UModel.NickName = Model.nickname ?? ""; UModel.OpenID = Model.openid; UModel.Sex = Model.sex; UModel.City = Model.city ?? ""; UModel.Country = Model.country ?? ""; UModel.Privilege = new string[0]; UModel.Province = Model.province ?? ""; UModel.UnionID = Model.unionid ?? ""; return(UModel); }
/// <summary> /// 判断是否关注 /// </summary> /// <param name="AppId"></param> /// <param name="Openid"></param> /// <returns></returns> public static bool VerifyAttention(string AppId, string Openid) { try { Senparc.Weixin.MP.Entities.WeixinUserInfoResult Model = Senparc.Weixin.MP.CommonAPIs.CommonApi.GetUserInfo(WeChatDeploy.GetAccessToken(AppId), Openid); if (Model.subscribe == 0) { return(false); } else { return(true); } } catch (Exception) { return(false); } }