这里的前提是你已经成功配置了公众号的服务器接口信息,即微信公众号的开发之 服务器配置(一)所说的内容,微信服务器和公众号之间的沟通都通过这个地址,有且只有一个。
/// <summary>
/// 微信推送地址
/// </summary>
/// <returns></returns>
public string go()
{
string xml = "error";
if (Request.QueryString["echostr"] != null)
{
//signature 验证服务器地址的有效性
string signature = Request.QueryString["signature"].ToString();
string timestamp = Request.QueryString["timestamp"].ToString();
string nonce = Request.QueryString["nonce"].ToString();
string echostr = Request.QueryString["echostr"].ToString();
xml = renzhen(signature, timestamp, nonce, echostr);
}
else
{
//推送消息和事件
xml = ProcessRequest(HttpContext);
}
return xml;
}