public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; WeiXinLogin weiXinLogin = new WeiXinLogin(); string doAction = context.Request.QueryString["do"]; dynamic jsonObj = new JObject(); if (string.IsNullOrEmpty(doAction)) { context.Response.End(); return; } if ("qrlogin" == doAction) { } if ("getqrpic" == doAction) { } if ("getwxpic" == doAction) { jsonObj = weiXinLogin.GetWeiXinPic(); } if ("wxlogin" == doAction) { jsonObj = weiXinLogin.Login(context.Request.QueryString["uuid"], context.Request.QueryString["last"]); } context.Response.Write(JsonConvert.SerializeObject(jsonObj)); }
public static void Test() { string strGuid = Guid.NewGuid().ToString().Replace("-", ""); WeiXinLogin login = new WeiXinLogin(); string url = login.GetLoginUrl(strGuid); Logger.WriteLog(LogType.DEBUG, "url:" + url); }
public ActionResult Index() { if (WeiXinLogin.ExecLogin("email", "password")) { return(RedirectToAction("GetInfo")); } return(View()); }
/// <summary> /// 消息处理 /// </summary> /// <returns></returns> public static string MsgFeedback() { bool bGetFans = WeiXinTool.OpenIdToFans(WeiXinMsgInfo.OpenId); string[] aMPInfo = WeiXinTool.GetMPUserInfo(WeiXinMsgInfo.OriginalId); string[] aServerId = WeiXinTool.GetMPServerId(WeiXinMsgInfo.OriginalId); WeiXinBindInfo.MPUser = aMPInfo[0]; WeiXinBindInfo.MPPass = aMPInfo[1]; WeiXinLogin.ExecLogin(WeiXinBindInfo.MPUser, WeiXinBindInfo.MPPass); if (bGetFans) { foreach (string sServerId in aServerId) { if (sServerId == WeiXinFans.sFakeId) { return(ServerBack()); } } } if (aMPInfo == null) { return("客服系统配置出现问题,如果你是本系统管理员请进入后台完成相关设置。"); } WeiXinBindInfo.BreakMsg = Guid.NewGuid().ToString().Substring(0, 5); if (!bGetFans) { string sOutText = string.Format("您是首次使用“微客服”平台,将会为您自动注册到客服系统,如果在5秒内收到绑定成功信息则代表注册成功!<a href=\"http:////RMBZ.Net\\{0}\"> </a>", WeiXinBindInfo.BreakMsg); WritePage(sOutText, false); Thread.Sleep(2500); string[] aFakeId = Bind.MPBind.BindFakeId(WeiXinBindInfo.BreakMsg, WeiXinBindInfo.MPUser, WeiXinBindInfo.MPPass); if (aFakeId.Length == 2) { WeiXinFans.sFakeId = aFakeId[0]; string sSql = string.Format("INSERT INTO `mpserver_bridge` (`openid`, `fakeid`, `name`, `time`) VALUES ('{0}', '{1}', '{2}', '{3}')", WeiXinMsgInfo.OpenId, aFakeId[0], WeiXinTool.Base64Code(aFakeId[1]), DateTime.Now); CDBAccess.MySqlDt(sSql); SendMsg.SendMessageText(aFakeId[1] + " 绑定成功,现在您就可以和客服联系啦。", WeiXinFans.sFakeId); } else { //WriteFile.Write("log.txt", WeiXinMsgInfo.OpenId + ":NoFoundFakeId.\n"); } return("OK"); } else { if (aServerId == null) { return("无法联系到客服!\n\n本客服系统尚未设置客服人员ID,请管理员尽快设置!"); } else { string sServerId = aServerId[0]; string MsgText = string.Format("来自 {0} 的消息:\n\n{1}\n\n回复此消息请回复“{2}#回复内容”", WeiXinFans.sNickName, WeiXinMsgInfo.Text, WeiXinFans.sFansId); SendMsg.SendMessageText(MsgText, sServerId); return("消息已经送达至客服,我们会尽快为您做答复!\n回复“退出”可退出“微客服”平台。"); } } }
/// <summary> /// FakeIdBind /// </summary> /// <param name="sBreakMsg">关键字</param> /// <param name="sMPUser">MP帐号</param> /// <param name="sMPPass">MP密码</param> /// <param name="sCookies">MPCookies</param> /// <returns>返回FakeId</returns> public static string[] BindFakeId(string sBreakMsg, string sMPUser, string sMPPass) { if (!WeiXinLogin.ExecLogin(sMPUser, sMPPass)) { return(new string[] { "客服暂时繁忙,无法为您解决问题。\nERROR CODE:ERROR_MPSERVER_LOGIN_FAILURE" }); } else { string[] aFakeIdInfo = GetRecentMessageListFakeId(sBreakMsg); if (aFakeIdInfo == null) { return(new string[] { "ERROR_NO_FAND_FAKEID" }); } return(aFakeIdInfo); } }