Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Advanced Group text in the Development of asp.net Wechat

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you about the example analysis of advanced mass text in the development of asp.net Wechat, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's go and understand it.

First of all, let's explain the process of sending mass text messages. My personal development program requires UI to write code. The interface is as follows.

If we look at the picture, we can also see that first of all, if we want to get the WeChat account, we will be able to send several messages in groups this month. As for how to calculate, that is, to send a message successfully in the local database, a message will be stored in the local database to calculate the number of messages (I believe it will). If it is more than 4, it cannot be sent (here I have already restricted it to death, because the service number can only send 4 messages per month, and it is useless to send more messages. Users can only receive 4 messages. Unless you use the preview function, send it one by one, but the preview function can only be sent 100 times. Maybe you can send more N times by sending mass messages in developer mode, because after I have sent mass messages twice, when I enter the official website of Wechat public platform, I can see 4 messages in mass, which is a bit depressing. ), the group object can be selected for all users or group users, and since the number of group messages is saved, I will not test the group text messages here. For more information, please refer to the following code:

Bind the number of messages sent in the remaining group this month

/ private void BindMassCount () {WxMassService wms = new WxMassService (); List wxmaslist = wms.GetMonthMassCount (); / / the official Wechat service can only send 4 messages per month. (one message a day by Subscription account) will not be successfully pushed. It has been set to 4 this.lbMassCounts.Text = (4-int.Parse (wxmaslist.Count.ToString ()). ToString ()). If (wxmaslist.Count > = 4) {this.LinkBtnSubSend.Enabled = false; this.LinkBtnSubSend.Attributes.Add ("Onclick", "return confirm ('mass messages have reached the limit! Please try again early next month!') ;} else {this.LinkBtnSubSend.Enabled = true; this.LinkBtnSubSend.Attributes.Add ("Onclick", "return confirm ('are you sure you want to send this message in bulk?)") ;}}

Binding grouping list

/ bind grouping list / private void BindGroupList () {WeiXinServer wxs = new WeiXinServer (); / / read accesstoken string Access_token = Cache ["Access_token"] as string; if (Access_token = = null) {/ / if empty, retrieve Access_token = wxs.GetAccessToken () / / set cached data to expire after 7000 seconds Cache.Insert ("Access_token", Access_token, null, DateTime.Now.AddSeconds (7000), System.Web.Caching.Cache.NoSlidingExpiration);} string Access_tokento = Access_token.Substring (17, Access_token.Length-37); string jsonres = ""; string content = Cache ["AllGroups_content"] as string If (content = = null) {jsonres = "https://api.weixin.qq.com/cgi-bin/groups/get?access_token=" + Access_tokento; HttpWebRequest myRequest = (HttpWebRequest) WebRequest.Create (jsonres); myRequest.Method =" GET "; HttpWebResponse myResponse = (HttpWebResponse) myRequest.GetResponse (); StreamReader reader = new StreamReader (myResponse.GetResponseStream (), Encoding.UTF8); content = reader.ReadToEnd (); reader.Close () / / set cached data to expire after 7000 seconds ("AllGroups_content", content, null, DateTime.Now.AddSeconds (7000), System.Web.Caching.Cache.NoSlidingExpiration);} / / reference Newtonsoft.json.dll file JObject jsonObj = JObject.Parse (content); int groupsnum = jsonObj ["groups"] .Count (); this.DDLGroupList.Items.Clear (); / / clear for (int I = 0; I)

< groupsnum; i++) { this.DDLGroupList.Items.Add(new ListItem(jsonObj["groups"][i]["name"].ToString() + "(" + jsonObj["groups"][i]["count"].ToString() + ")", jsonObj["groups"][i]["id"].ToString())); } } /// /// 选择群发对象类型,显示隐藏分组列表项 /// /// /// protected void DDLMassType_SelectedIndexChanged(object sender, EventArgs e) { if (int.Parse(this.DDLMassType.SelectedValue.ToString()) >

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report