Experience the rapid development framework of WeChat public platform

Source: Internet
Author: User

This morning I tried to use that framework to quickly establish a test. I found some bugs and fixed them quickly. Now I have updated them to github.

Next, for quick development, first you need to create a public account to test the account. For the creation method, see create a public platform test account. In the project, I added the WebDemo project, you can refer to the following.

In the previous introduction, I said that you should first create a rule, but think about the following. It seems that you must first create a message processing class before using it in the rule.

In practice, here I use two messages for processing, one is DefaultMessageHandler and the other is CnBlogsMessageHandler, and the other is the default message. If the message cannot be processed, it is returned. CnblogsMessageHandler is a text message processing, you only need to reply to "blog" to see the corresponding feedback.

Create two MessageHandler to inherit IMessageHandler:

 
 

Follow these rules:

Here I have created several sets of rules and first set up the subject Rules:

 

MsgTypeMessageRole is a type-based processing rule. Unlike the previous Demo, I subdivided the rules so that the coupling degree is reduced and can be modified in different rules according to different requirements.

 

When it is determined as Text, another message processing rule is returned. In other cases, a default message processing rule is returned.

 

It is a simple rule class. I just judge whether the text content contains the word "blog Garden". If there is one, I will return it directly.

The basic processing is complete. Next, deploy the interface. In the web Project, wx. aspx is the interface address.

My public test address: http://wx.jamesying.com/wx.aspx

Make some necessary configurations in wx. aspx. cs:

 

So far, a simple public platform interface has been configured, as long as it is deployed to its own web server. In the previous article, someone mentioned that there was an interface + factory model. To be honest, I have never seen it. It may be a bit lazy recently, but I have never been using blog parks. However, I read an article about the platform by @ junjian and thought it was well written. You can also take a look.

The purpose of this framework is to facilitate development. Yesterday, a user said that it is better to provide some templates (in fact, MessageHandler). I think this solution is good, in a few days, I will apply for a public account and write several common processing classes for your convenience. You can also write it by yourself and Email it to me.

The following shows the effect. If you want to view the effect, please pay attention to my test account (you must scan the QR code by scanning the QR code ):

I used web weixin:

Follow me: jamesying1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.