Sharing of research on Android third-party application access to wechat platform (I)

After the opening of wechat platform, it is very popular. Many third-party applications want to try to access wechat platform. After all, it is good to use the relationship chain established by wechat to expand their applications, which can save a lot of social expenses. Recently, I have been studying this thing due to practical needs, but I found that there are still very few relevant information on the Internet, Here I give out my whole research situation, hoping to learn together.

1、 Class diagrams of main classes will be used in wechat SDK

The above class diagram shows the request class and response class in the process of communication with wechat. Third party applications use them

The attached message field is used to carry the message to the wechat process. Baseresp has an internal class, errCode,

It defines several constant fields. When we send a request to wechat, it will be used as a return field

Back to our application, we can do the corresponding processing according to this, which will be mentioned in the following sequence diagram

Yes. Next is the message object in the SDK.

The above class diagram is mainly message objects. There is a field to refer to media objects. These media objects are

It is the object we can send to wechat. With the message object and media object, the next thing to give is to cancel

The communication class sent by the information object.

The iwxapi above is the so-called communication class. He is doing all the work of communicating with wechat, and his

The generation is completed by the following factory class. The iwxapieventhandler interface next to it requires third-party applications

If we want to process the request information of wechat or the identification field returned after we send a request to him.

2、 Timing diagram of third-party application and wechat communication

1. Send message to wechat

The application only needs to register once, and then in future use, it only needs to encapsulate the message and let the communication class

Just send. As can be seen from the previous class diagram, the order of encapsulating messages is to generate the media to be sent first

Object, then attach the media object to the message object, then establish the request object, and finally send it using the communication class

Just send it. The code is as follows:

Several renderings are given below:

After program entry

After registration, click send, and wechat will give a list of friends

Select a friend and an additional message editing interface will appear without filling in anything

Click share to return to the third-party application and receive the sent message in friends' wechat

It is added here that the frame in the figure is the display appearance of the message object defined by wechat itself, which is not defined by a third-party application. You can know by comparing it with the previous figure.

For the time being, it seems that this blog can't carry so many things. The rest will be given in the following articles. Thank you.

Because the demos I wrote myself were lost after the internship, I gave an official demo to download. If there is anything unclear, I can communicate. Thank you for your cooperation and hope to learn together.

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
分享
二维码
< <上一篇
下一篇>>