作者:夏乐迎1 | 来源:互联网 | 2017-05-11 01:14
1.0启用开发者模式
①填写服务器配置
启用开发模式需要先成为开发者,而且编辑模式和开发模式只能选择一个(进入微信公众平台=>开发=>基本配置)就可以看到以下的界面:
开发者通过检验signature对请求进行校验(下面有校验方式)。若确认此次GET请求来自微信服务器,请原样返回echostr参数内容,则接入生效,成为开发者成功,否则接入失败(注意:微信服务器只支持80端口)。
使用GET请求带上以上参数请求服务器,具体实现代码:
public void InterfaceTest()
{
string token = "配置时填写的token";
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();
}
}
更多C#微信开发系列-启用开发者模式相关文章请关注PHP中文网!