求解 asp.net 获取post 微信xml数据
已写代码 如下
protected void Page_Load(object sender, EventArgs e)
{
if (Request.HttpMethod.ToLower() == "post")
{
Stream s = System.Web.HttpContext.Current.Request.InputStream;
byte[] b = new byte[s.Length];
s.Read(b, 0, (int)s.Length);
string postStr = Encoding.UTF8.GetString(b);
if (!string.IsNullOrEmpty(postStr))
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(postStr);
XmlNodeList list = doc.GetElementsByTagName("xml");
XmlNode xn = list[0];
string FromUserName = xn.SelectSingleNode("//FromUserName").InnerText;
string ToUserName = xn.SelectSingleNode("//ToUserName").InnerText;
string content = "", menu = "";
content = xn.SelectSingleNode("//Content").InnerText;
if (content.Equals("HelloV2V"))
{
menu = "欢迎xxx";
}
else
{
menu = "现在是北京时间:" + string.Format("{0:f}", DateTime.Now);
}
string strresponse = "<xml>";
strresponse = strresponse + "<ToUserName><![CDATA[" + FromUserName + "]]></ToUserName>";
strresponse = strresponse + "<FromUserName><![CDATA[" + ToUserName + "]]></FromUserName>";
strresponse = strresponse + "<CreateTime>" + DateTime.Now.Ticks.ToString() + "</CreateTime>";
strresponse = strresponse + "<MsgType><![CDATA[text]]></MsgType>";
strresponse = strresponse + "<Content><![CDATA[" + menu + "]]></Content>";
strresponse = strresponse + "<FuncFlag>0<FuncFlag>";
strresponse = strresponse + "</xml>";
WriteLog("postStr:" + content);
Response.Write(strresponse);
Response.End();
}
}
} asp.net xml
[解决办法]
只做过微信分享功能,不过要在微信客户端中打开网页才能用,楼主强大,居然能获取微信数据,貌似腾讯的东西,数据都是加密的吧?
[解决办法]
是分享吗?问题在哪?