Use delphi + intraweb to process WeChat messages

Source: Internet
Author: User
In the second lecture, we used delphi + intraweb for development. net Release (with asp. netmvc4 mode deployment) in IIS (.. net virtual host), we have successfully deployed the iw application on the cloud virtual host. in this lecture, we will continue with the content of the first lecture for regression development. This lecture will explain message processing. In the second lecture, we used delphi + intraweb for development. net (deployed in asp.net mvc4 mode) in IIS (.. net virtual host), we have successfully deployed the iw application on the cloud virtual host. in this lecture, we will continue with the content of the first lecture for regression development. This lecture will explain message processing.

First, clarify several knowledge points:

1. the http post method used by the server to forward user messages. in the first lecture, we did not elaborate on the http data submission method of the server. In fact, the http get method is used for access verification; the http post method is used to forward user messages, and the messages are encoded in xml format when the messages are forwarded. ContentType = text/xml.

2. three data transmission methods can be selected for Server Message Forwarding: 1. plaintext; 2. encryption; 3. hybrid. In this section, we use plaintext to transmit data for debugging convenience. Next, I will explain how to process the message encryption method.

It seems that the content of this lecture is not difficult. if it is. net, php, or even webbroker of delphi, it should be easy to implement. However, after using iw, the problem found to be complicated!

The iw class for processing http request data is THttpRequest. However, after reading THttpRequest attributes and methods, I did not find the direct access to http content. only one class seems to be THttpRequest for reading http content. contentFields attribute, but after the code is executed and debugged, it is found that this attribute cannot be obtained from the xml file passed by the server, and the content is always blank.

After verification, it is found that the ContentFields attribute is valid only for the content that is passed when ContentType is application/x-www-form-urlencoded in http request, that is to say, data can be obtained for form-type submission. in the first lecture, this is the case. the passed signature, timestamp, nonce, and other field values can all be obtained through THttpRequest. contentFields.

Things have been in full trouble till now. how can I use the THttpRequest class method to retrieve content when ContentType = text/xml? After research, we found that the THttpRequest class has a file attribute. at that time, I felt that I wanted it to be on this attribute. after all, xml can also be uploaded as Files, right? Haha, unfortunately, no matter how I tried it (the decompiling dcu was used), the number of files in this attribute was always 0, and the hope was broken!

As a result, posting a message on the iw official issue Post Forum began to seek advice. no one returned the message within one or two days, after searching for related questions, I found that someone had encountered the same problem as me. at that time, the author gave a response saying that the questioner was not clear and asked to send an email to the author's code, I caught it. I immediately pretended to be the questioner and sent my code to the author and attached a question. sorry, it's not that easy for iw to love you.

There is no way to continue searching for other people's questions. However, I finally found a post where the questioner and my questions are different, but the respondent mentioned that there is a PostFormData sample project in iw demos, check my downloaded demo and find that there is no such project. download the example project again on the official website! Open the code and check it! The same as the first lecture is that a line of code is uncomfortable for me for several days.

Let's see:

End;

For more articles about message processing using delphi + intraweb, please follow the 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.