In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the example analysis of the interaction and interface of Wechat public platform in php. The article is very detailed and has certain reference value. Interested friends must finish reading it!
The details are as follows
1. Interaction between Wechat users, Wechat server and backend server
Example: the Wechat user sends a text message to the official account, which is first transmitted to the Wechat server. The Wechat server processes the information and transmits it to the background server in xml data format. The background server receives the data, and then processes the data, and then transmits the response data to the Wechat server in xml data format, and the Wechat server responds to the user Wechat interface.
The interaction between Wechat users and Wechat background server is the process of data transmission, but it needs to go through the transit station of Wechat server.
So what is the use of Wechat server as a transit station?
The xml data are processed and packaged and displayed on the mobile phone screen. The picture and text messages we receive are as follows:
Single picture and text:
Multi-picture and text
You will find that almost all the pictures and texts on Wechat are in this format, with the same plate and size. This is the result after being packaged by Wechat server.
2. Data types of interaction
The types of data that Wechat users can send
1. Text type (text)
% s "
2. Voice (voice)
% s5836982871638042400//recognition represents the result of speech recognition
3. Picture (img)
% s5836982871638042400
Every message sent to the Wechat server will be marked with a MsgId, and the uploaded pictures, videos, voice messages, etc., will also be marked with a mediaId.
4. Video (video)
% s5836982871638042400 the picture address is displayed when the video is still.
5. Geolocation message (location)
% s583698287163804240022.539968113.95498016
6. Link message (link)
% s58369828716380424005839907284805129867
Message type of response from the background server
1. Text type (text)
2. Voice (voice)
% s5836982871638042400
3. Picture (img)
% s5836982871638042400
4. Video (video)
% s5836982871638042400 the picture address is displayed when the video is still.
5. Music (music)
% s5836982871638042400
6. Picture and text (news)
% s5836982871638042400% s
The above code only serves as a reference for data filling. The above code can be called when needed, here is just to show you the following data format.
CDATA is a tag that is not parsed by the xml parser in the text data it marks. A CDATA part to "
ToUserName recipient account number
FromUserName sender account
CreateTime send event
MsgType data type
Content text content
Number of ArticleCount pictures and texts
MsgId data id
MediaId Media id
Title title
Description description
MusicUrl Music connection address
HQMusicUrl High quality Music connection address
2. The specific interaction step is the code
In figure 2 of the previous chapter, we defined url and token for the test number. Url is the address of the background server that communicates with the Wechat server, and token is equivalent to a token. When the Wechat server communicates with the background server, it will show the token, and if the background server finds that the Wechat server is the same as the token it carries, it will communicate, and if it is different, it will refuse to communicate. This process is called token authentication (this token is not the value of token).
The above is more vivid, and I will explain it through the code below.
For example: url is http://weixinceshi111111.applinzi.com/index2.php
Token:weixin
Index2.php code
3. Interface
3.1 what is the interface
The interface is equivalent to a tool with specific functions. For example, if you need to drill holes in the wall when you are building a house, you will use drilling rig tools to drill holes. From the transfer of tools to drilling, you have to complete a series of steps such as plug-in, calibration, drilling and so on, and finally achieve your goal. The drilling rig is our interface, and plug-in, calibration and drilling are the steps for us to use the tools to complete the goal.
An example of an API for creating menus on Wechat.
To call an API:
1. Get the connection address of the Wechat menu interface and establish a dialogue with this interface through the curl function.
2. Send the creation menu data to this interface.
The API is called, and the interface will automatically process the data and generate a menu on the Wechat public good page.
The above is all the contents of the article "sample Analysis of Wechat Public platform interaction and Interface in php". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.