Java wechat public platform development (8) multimedia message reply

When we replied to messages, we simply classified the replied messages, The above also describes how to reply to [ordinary message type message]. Here will describe the reply method of multimedia message. The [multimedia message] includes replying to picture message / replying to voice message / replying to video message / replying to music message. Here, take the reply of picture message as an example!

Remember that the previous criteria for message classification is that one does not need to upload multimedia resources to Tencent server, and the other is required, so the first step we need to do here is to upload resources to Tencent server, Here we call the [material management] interface (which will be described in a special chapter later) to upload pictures. The same interface can provide us with the management of voice, video, music and other messages. Here, take pictures as an example (document address: http://mp.weixin.qq.com/wiki/10/10ea5a44870f53d79449290dfd43d006.html )。 In the document, we can find that the upload method here is to simulate the form upload, and then return to us the parameter we need to use in the reply message: media_ id!

(1) Material interface picture upload

Write the URL of the interface request to the configuration file interface according to our previous agreement_ url. In properties:

Then I wrote a tool class httppostuploadutil. For simulating form upload here Java, as follows:

After we have written the tool class, we need to add the corresponding response code to our message reply. Here, I add the response code to [attention events] for testing!

(2) Picture reply

What we need to modify here is the code of our event message service distributor. Here we add our reply to the attention event. The simple code is as follows:

Here, the code has basically completed the content of the whole picture message reply. Similarly, the processes of voice reply and video reply are the same, so we don't talk too much about others. The final general effects are as follows:

We'll talk about the content of normal message reply. In the next article, we'll talk about the implementation of some applications [keyword reply and hyperlink reply] Based on message reply. Thank you for reading. If you have any questions, you can leave a message for discussion!

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>