public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //签名验证 if (context.Request["id"] != null && context.Request["sign"] != null && context.Request["nonce_str"] != null) { string request_sign = context.Request["sign"]; string nonce_str = context.Request["nonce_str"]; string timestamp = context.Request["timestamp"]; int id = int.Parse(context.Request["id"]); if (AgentSign.CheckRequestSign(request_sign, nonce_str, timestamp, id)) { if (!CheckConfig(id)) { context.Response.Write("abort config"); context.Response.End(); } AccessTokenObject tokenObject = new Token().Get(); context.Response.Write(JsonHelper.ScriptSerialize(tokenObject, false)); } else { context.Response.Write("abort signature"); } } else { context.Response.Write("abort signature request"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //签名验证 if (context.Request["id"] != null && context.Request["sign"] != null && context.Request["nonce_str"] != null) { string request_sign = context.Request["sign"]; string nonce_str = context.Request["nonce_str"]; string timestamp = context.Request["timestamp"]; int id = int.Parse(context.Request["id"]); if (AgentSign.CheckRequestSign(request_sign, nonce_str, timestamp, id)) { if (context.Request["url"] == null) { context.Response.Write("abort request"); context.Response.End(); } string url = context.Request["url"]; string encode = context.Request["encode"]; if (string.IsNullOrWhiteSpace(encode)) { encode = "false"; } Signature signature = new Signature(); context.Response.Write(signature.Get(url, encode)); } else { context.Response.Write("abort signature"); } } else { context.Response.Write("abort signature request"); } }
public void ProcessRequest(HttpContext context) { //ILog logs = LogManager.GetLogger("index"); context.Response.ContentType = "text/plain"; //签名验证 if (context.Request["id"] != null && context.Request["sign"] != null && context.Request["nonce_str"] != null) { string request_sign = context.Request["sign"]; string nonce_str = context.Request["nonce_str"]; string timestamp = context.Request["timestamp"]; int id = int.Parse(context.Request["id"]); string sn = new GZH.CL.Config.AgentConfig().GetItem(id).sn; if (AgentSign.CheckRequestSign(request_sign, nonce_str, timestamp, id)) { if (context.Request["scope"] == null || context.Request["redirect"] == null) { context.Response.Write("abort request"); context.Response.End(); } if (!CheckConfig(id)) { context.Response.Write("abort config"); context.Response.End(); } string scope = context.Request["scope"]; string callback_url = context.Request["redirect"]; if (!string.IsNullOrWhiteSpace(scope) && callback_url.IndexOf("http://") != -1) { string state = scope == "snsapi_userinfo" ? "1" : "0"; state += "|" + id; string redirect_uri = "http://" + HttpContext.Current.Request.Url.Host + "/api/authorize/redirect_uri.ashx"; string requestUri = ConfigSetting.GetWeixinWeb().AuthorizeUrl; callback_url = context.Server.UrlEncode(callback_url); redirect_uri += "?callback_url=" + callback_url; requestUri += "?appid=" + ConfigSetting.GetWeixin().AppID; requestUri += "&redirect_uri=" + context.Server.UrlEncode(redirect_uri); requestUri += "&response_type=code&scope=" + scope + "&state=" + state + "#wechat_redirect"; context.Response.Redirect(requestUri); } } else { context.Response.Write("abort signature"); } } else { context.Response.Write("abort signature request"); } }