微信开发最重要的一步(服务器配置)

来源:互联网 发布:java相关文献 编辑:程序博客网 时间:2024/05/18 13:27

智学无忧的教学系统打算开发微信版本,目的是利用微信的方便,为智学无忧的同学提供更加的遍历服务。开发第一步遇到坑了,拿出来和大家分享,希望对网友有帮助


1. 微信公众号要认证,我们的已经是认证的了


2.进入服务器配置(这个地方有坑)


       

    查了各种资料,才知道,这个地方是随意填的,核心的目的就是验证这个网站或服务器是有效的而已。微信根据上面提供的地址,发送一个get请求。请求的信息为

   echoStr  、signature、timestamp、nonce

 其实就是返回echoStr  即可,其它的参数不用理会。主要目的就是验证这个服务器是否有效。

我的后台语言是C#的,所以贴上我的代码 

    public partial class Default : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {            string token = "zxwyit";            if (string.IsNullOrEmpty(token))            {                return;            }            string echoString = HttpContext.Current.Request.QueryString["echoStr"];            string signature = HttpContext.Current.Request.QueryString["signature"];            string timestamp = HttpContext.Current.Request.QueryString["timestamp"];            string nonce = HttpContext.Current.Request.QueryString["nonce"];            if (!string.IsNullOrEmpty(echoString))            {                HttpContext.Current.Response.Write(echoString);                HttpContext.Current.Response.End();            }          }    }

验证通过后,进入网站的首页就可以换掉了。

最简洁的代码

public partial class Default : System.Web.UI.Page{        protected void Page_Load(object sender, EventArgs e)        {            string echoString = HttpContext.Current.Request.QueryString["echoStr"];            Response.Write(echoString);                      }}



原创粉丝点击