Micro-Credit public development: using the Message interface

Source: Internet
Author: User

Previously wrote a post that builds the SAE Python platform, validated by a micro-trust public platform. Now is to the connecting link, began to develop the first step. Perhaps you would say that the first step in development is to write code. Then I will show contempt for you, although the Nanyuan essay is a very simple application, but also need to design a little bit. To identify the needs and to attract fans to pay attention to my public number in the future, I have to locate my app, provide good content, and determine its operating model to further improve our application.

Demand analysis

First of all, this app is written in Python, so be sure to be elegant and pythonic. For myself, I'm going to make this app at least as good as I need to read a few articles related to Nanyuan. Therefore needs to the Nanyuan essay needs Analysis:

Positioning: For Nanyuan or outside students to provide our life and study in the Nanyuan article. The style is not limited, the content form includes {picture, voice, text}, push to the user, this is precisely the micro-letter can provide to me.

Agreement: Permission to contribute, but the submission must be audited by the administrator. In fact, to a large extent, we are in order to recommend to the fans @bibo-jelly and @daoluan-Zheng willing to cooperate with the "Nanyuan essay--it Little Bird."

Content: Campus Life, learning, feelings, sharing, fun, photography, literature, simple social, songs and so on.

Services: Provide regular tweets or voice mail every 1 days/2 days. At the same time, the corresponding user sent the request, analysis of the user request to return the requested content.

Performance: Requires the server to return the user's request within 5 seconds, when the network is poor, this is hard to say. To be able to handle at least 20 fans at the same time (in fact, there are so many fans to ask, I still do not count AH).

System Design

This time, I learned from the last lesson, to complete the design of logic and data, and finally to design our interactive interface (including interactive mode and menu). Data first, everything starts with building the database. Referring to WordPress's blog database, you can design a basic database framework. This is part of the @daoluan-think-ready, and I'm sure he'll do quite well.

The system needs a blog system, and a micro-mail service app, the blog system as a web-side, with the browser accessible. and micro-mail app is responsible for pushing to the user's micro-mail account chat interface. Therefore, our database design is very clear, we need:

User Table--users

Post Table--article

Blog configuration--Blogging settings

Category table--classification

——————————— Secondary ———————————

URL Table--Links

Guest_book Table--Guestbook

And what I need to use is just a subset of the blog system database--post tables and Guest_book tables (may use category tables). Therefore, the development of micro-letter app only need to create two tables to experiment.

Send Message Test

Instead of putting design logic on the agenda, let's try to communicate with a Third-party server and a micro-trust server, as well as the client. If a user sends a request, because the URL is already bound and the development mode is turned on, the micro-trust server forwards the request to our server, our server resolves the request, and then returns the requested content.

We need a class to handle get requests, and articles that send mass to a micro-server on a regular basis.

This type of Weixin_scnuwriter is designed as follows:

Handle_request (Request) # Processing requests

Parse_request_xml (XML) # Parsing requests

Response_msg (Request) # Responding to requests (key logical parts)

Pack_text_xml (Post_msg, response_msg) # Package The text content of the response, need to refer to the micro-credit API for Response_msg call

# In addition to the database to be able to read, you need Django to deal with the database, but we do not implement, just to do a simple test.

Here's the Handle_request code:

def handle_request (Request):    
    if Request.method = = ' Get ':    
        response = HttpResponse check_signature (request), Content_type= "Text/plain")    # If it is a GET request, then check the signature return   
        response   
    elif request.method = ' POST ':     
        Response = HttpResponse (response_msg (Request), content_type= "Application/xml")  # if it is a POST request, then respond to the message return   
        Response    
    Else: return    
        None

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.