We've talked before about sending micro-letters to our regular text messages, let's take a look at how to send text messages, note that this is said here, let the micro-mail to us, rather than we take a picture sent to the micro-letter processing, we upload pictures in the next chapter. Here is the function to send a message, involves title (title), description (abstract), picurl (picture), link (URL) several key parameters:
Protected string Sendpictextmessage (Msg _mode,string title,string description,string picurl,string url)
{
string res = string. Format (@ "<xml>
<tousername><![ Cdata[{0}]]></tousername>
<fromusername><![ cdata[{1}]]></fromusername>
<CreateTime>{2}</CreateTime>
<msgtype><![ cdata[news]]></msgtype>
<ArticleCount>1</ArticleCount>
<Articles>
< Item>
<title><![ Cdata[{3}]]></title>
<description><![ Cdata[{4}]]></description>
<picurl><![ Cdata[{5}]]></picurl>
<url><![ cdata[{6}]]></url>
</item>
</Articles>
</xml> ",
_mode. Fromusername, _mode. Tousername, Datetime.now,title, description, Picurl, URL);
return res;
}
Directly in the call function can:
protected void Page_Load (object sender, EventArgs e) {mymenu ();
Wxmessage WX = Getwxmessage ();
string res = ""; if (!string. IsNullOrEmpty (WX. EventName) && WX.
Eventname.trim () = = "Subscribe") {String content = "";
Content = "/:rose welcome Beijing Yong Jie Friend Letter Technology Co., Ltd./:rose\n directly reply" Hello ";
res = sendtextmessage (wx, content); else if (!string. IsNullOrEmpty (WX. EventName) && WX. Eventname.trim () = = "click" {if (WX).
eventkey== "Hello" res = sendtextmessage (wx, "Hello, Welcome to use Beijing Yong Jie Xin Technology Co., Ltd. Public micro-letter platform!"); if (WX).
eventkey== "P1" res = Sendtextmessage (wx, "Hello, click on product 1"); if (WX).
eventkey== "P2" res = Sendtextmessage (wx, "Hello, click on product 2"); else {if (WX. Msgtype = = "Text" && wx.
Content = = "Hello") {res = Sendtextmessage (wx, "Hello, Welcome to use Beijing Yong Jie Xin Technology Co., Ltd. Public micro-letter platform!"); } if (WX. Msgtype = = "Text" && wx. Content = = "text") {res = SendpictextmessaThe GE (WX, "Here is a title", "Here is the summary", "Http://mp.weixin.qq.com/wiki/skins/common/images/weixin_wiki_logo.png", "http://
Www.4ugood.net "); else if (WX. Msgtype = = "Voice") {res = Sendtextmessage (WX, WX.
recognition);
else {res = Sendtextmessage (wx, "Hello, failed to recognize message!");
} Response.Write (res);
Private Wxmessage Getwxmessage () {wxmessage wx = new Wxmessage ();
StreamReader str = new StreamReader (Request.inputstream, System.Text.Encoding.UTF8);
XmlDocument xml = new XmlDocument (); Xml.
Load (str); Wx. Tousername = XML. selectSingleNode ("xml"). selectSingleNode ("Tousername").
InnerText; Wx. Fromusername = XML. selectSingleNode ("xml"). selectSingleNode ("Fromusername").
InnerText; Wx. Msgtype = XML. selectSingleNode ("xml"). selectSingleNode ("Msgtype").
InnerText; if (WX). Msgtype.trim () = = "Text") {WX. Content = XML. selectSingleNode ("xml"). selectSingleNode ("Content").
InnerText;} if (WX. Msgtype.trim () = = "Event") {WX. EventName = XML. selectSingleNode ("xml"). selectSingleNode ("Event").
InnerText; Wx. Eventkey = XML. selectSingleNode ("xml"). selectSingleNode ("Eventkey").
InnerText; } if (WX. Msgtype.trim () = = "Voice") {WX. Recognition = XML. selectSingleNode ("xml"). selectSingleNode ("Recognition").
InnerText;
return WX;
}
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.