// GET: /WeChat/Home/Index // public ActionResult Index() // { // var content = "success"; // #region 记录日志 // /*yyyy.MMMM.dd.hh.mm.ss*/ // try // { // var test1 = @"<xml><ToUserName><![CDATA[gh_fc4c31ef2ade]]></ToUserName> //<FromUserName><![CDATA[oe4J2uAJoapkwmf039OcFy_YwVMw]]></FromUserName> //<CreateTime>1478029372</CreateTime> //<MsgType><![CDATA[text]]></MsgType> //<Content><![CDATA[哦哦]]></Content> //<MsgId>6348087815716601133</MsgId> //</xml>"; // var test2 = @"<xml><ToUserName><![CDATA[gh_fc4c31ef2ade]]></ToUserName> //<FromUserName><![CDATA[oe4J2uAJoapkwmf039OcFy_YwVMw]]></FromUserName> //<CreateTime>1478029372</CreateTime> //<MsgType><![CDATA[text]]></MsgType> //<Content><![CDATA[哦哦]]></Content> //<MsgId>6348087815716601133</MsgId> //</xml>"; // //content = _wechatServices.MsgHandle(test1); // //content = _wechatServices.MsgHandle(test2); // content = _wechatServices.MsgHandle(XmlRequstBody); // } // catch (Exception ex) // { // //小熊正在给公众号升级,晚些再来吧,么么哒~ // content = string.Format(@"<xml> // <ToUserName><![CDATA[{0}]]></ToUserName> // <FromUserName><![CDATA[{1}]]></FromUserName> // <CreateTime>{2}</CreateTime> // <MsgType><![CDATA[text]]></MsgType> // <Content><![CDATA[{3}]]></Content> // </xml>", Message.FromUserName, // Message.ToUserName, Message.CreateTime, // "小熊正在给公众号升级,晚些再来吧,么么哒~"); // WriteFile(string.Format("UserFiles\\Test\\Error-{0}.txt", DateTime.Now.ToString("yyyy.MM.dd.dd.hh")), // ParseException(ex), false); // } // #endregion // WriteFile(string.Format("UserFiles\\Test\\log-{0}.txt", DateTime.Now.ToString("yyyy.MM.dd.dd.hh")), // RequstLog, false); // return Content(content.HasValue() ? content : "success"); // } // GET: /WeChat/Home/Token //url https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET public ActionResult Token() { var action = "Token"; Param.Add("grant_type", "client_credential"); Param.Add("appid", APP_ID); Param.Add("secret", APP_SECRET); var content = _wechatServices.ApiHttpGet(URL_WECHAT_HOST, action, Param, action); WriteFile( string.Format("UserFiles\\Test\\log-GetCallBackIp-{0}.txt", DateTime.Now.ToString("yyyy.MM.dd.dd.hh")), content, false); return(Content(content)); }