http://blog.csdn.net/hougelou/article/details/8462364
前几天刚写的,乱乱的,呵呵。
resxml = "<xml><ToUserName><![CDATA[" + requestXML.FromUserName + "]]></ToUserName><FromUserName><![CDATA[" + requestXML.ToUserName + "]]></FromUserName><CreateTime>" + ConvertDateTimeInt(DateTime.Now) + "</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[测试成功!!]]></Content><FuncFlag>0</FuncFlag></xml>";
推送回去的信息不成功,需要设置什么吗?
@snjsunyan: 不用设置啊,我哪里写入日志文本里,是想调试,方便自己看到到底是哪里出错。
找他的api看一下
protected void Page_Load(object sender, EventArgs e) { WeiXinMP.Sdk.WeiXinMPMessage mp = new WeiXinMP.Sdk.WeiXinMPMessage("token"); mp.Encoding = Encoding.UTF8; mp.ProcessReceivedMessage(ReplyWx); } private WeiXinMP.Sdk.ReplyMessage ReplyWx(WeiXinMP.Sdk.ReceivedMessage msg) { WeiXinMP.Sdk.ReplyMessage reply = new WeiXinMP.Sdk.ReplyMessage(); //msg.FromUserName reply.Content = "小秘书发来消息:" +RContent; reply.FromUserName = msg.ToUserName; reply.ToUserName = msg.FromUserName; reply.CreateTime = DateTime.Now; return reply; } /// /// 处理推送过来的消息 /// /// public void ProcessReceivedMessage(ReceivedMessageHandler processHandler) { //返回消息代码略................... string responseXml = "{2}{4}{5} "; RequestContext.Response.Write(string.Format(responseXml, reply.ToUserName, reply.FromUserName, GetTimeSpan(reply.CreateTime), reply.MsgType.ToString().ToLower(), contentXml, reply.FunFlag)); RequestContext.Response.End(); }
微信公众平台消息接口(.net C#)
包含“菜单接口” 和 “消息接口”
项目地址:https://github.com/chendong152/Weinxin_api_.net,直接下载使用
我们的目标是“几句代码完成处理”
演示:
//文本消息
var m = ReceiveMessage.ParseFromContext();
var r = m.GetTextResponse();
r.Data = (TextMsgData)"this is response";
r.Response();