protected void GetHeadImg(M_UserInfo mu) { if (mu == null || mu.IsNull || mu.UserID < 1) { } else { uappMod = uappBll.SelModelByUid(mu.UserID, "wechat"); M_WX_User wuserMod = new M_WX_User(); if (uappMod != null) { try { wuserMod = wxapi.GetWxUserModel(uappMod.OpenID); } catch (Exception ex) { wxapi.GetToken(); wuserMod = wxapi.GetWxUserModel(uappMod.OpenID); throw ex; } if (wuserMod != null) { Response.Write("{\"nickname\":\"" + wuserMod.Name + "\",\"headimgurl\":\"" + wuserMod.HeadImgUrl + "\"}"); } } } }
protected void ReToken_Btn_Click(object sender, EventArgs e) { WxAPI api = WxAPI.Code_Get(Mid); api.GetToken(); function.WriteSuccessMsg("已重新获取Token"); }
protected void GetHeadImg(M_UserInfo mu) { int appid = 1; if (AppID > 0) { appid = AppID; } WxAPI wxapi = WxAPI.Code_Get(appid); if (mu == null || mu.IsNull || mu.UserID < 1) { } else { uappMod = uappBll.SelModelByUid(mu.UserID, "wechat"); M_WX_User wuserMod = new M_WX_User(); if (uappMod != null) { try { wuserMod = wxapi.GetWxUserModel(uappMod.OpenID); if (string.IsNullOrEmpty(wuserMod.Name)) { wxapi.GetToken(); wuserMod = wxapi.GetWxUserModel(uappMod.OpenID); } } catch (Exception ex) { wxapi.GetToken(); wuserMod = wxapi.GetWxUserModel(uappMod.OpenID); throw ex; } if (wuserMod != null) { Response.Write("{\"nickname\":\"" + wuserMod.Name + "\",\"headimgurl\":\"" + wuserMod.HeadImgUrl + "\"}"); } } } }