Introduction to Basic concepts of WeChat public platform development

Source: Internet
Author: User
This article introduces the basic concepts of public platform development I. how to start

1: If there is no public account, you can apply for a test account: http://mp.weixin.qq.com/debug/cgi-bin/sandbox? T = sandbox/login

2: After logon, the interface is as follows:

3: Next, I need to prepare my own website and then publish my own URL. Therefore, I wrote a WeixinTest. ashx using ASP. NET. the code is as follows:

public void ProcessRequest(HttpContext context) {           string echoStr = HttpContext.Current.Request.QueryString["echoStr"];           string signature = HttpContext.Current.Request.QueryString["signature"];           string timestamp = HttpContext.Current.Request.QueryString["timestamp"];           string nonce = HttpContext.Current.Request.QueryString["nonce"];
    if (!string.IsNullOrEmpty(echoStr))          {               HttpContext.Current.Response.Write(echoStr);               HttpContext.Current.Response.End();           }       }

After the website is published on your server, we enter the address and TOKEN (note that the TOKEN is not verified in my test code ). Then, click submit in the figure above to get the interface:

It is worth noting that this value has an invalid period.

4. instance-a real url handler

public void ProcessRequest(HttpContext param_context)     {          if (HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")          {              using (Stream stream = HttpContext.Current.Request.InputStream)              {                  Byte[] postBytes = new Byte[stream.Length];                  stream.Read(postBytes, 0, (Int32)stream.Length);                  Handle(Encoding.UTF8.GetString(postBytes));                     }          }          else          {              Auth();      }      }

Why is it POST? When applying for a public account, the website uses GET to verify the url. in this way, we can use Auth to interact, POST is used. Next, we can start development in the true sense :)~~

Refer:

1: Developer files, http://mp.weixin.qq.com/wiki/index.php? Title = % E5 % BC % 80% E5 % 8F % 91% E8 % 80% 85% E8 % A7 % 84% E8 % 8C % 83

For more articles about basic concepts of public platform development, please refer to PHP Chinese network!

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.