In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "sample Analysis of Wechat Public account Development". The content is simple and clear. I hope it can help you solve your doubts. Now let the editor lead you to study and learn the article "sample Analysis of Wechat Public account Development".
Basic principles of Wechat Public account Development course
Before you start to do it, you may be very interested in this, but at a loss. Isn't it complicated? Is it hard to learn?
In fact, on the contrary, it is very simple. In order to allay everyone's concerns, this paper first briefly introduces the basic principles of Wechat public platform.
Wechat server is equivalent to a forwarding server, terminals (mobile phones, Pad, etc.) initiate requests to Wechat server, Wechat server, and then forward the request to the custom service (this is our specific implementation).
After the service is processed, it is volatilized to the Wechat server, and the Wechat server replies the specific response to the terminal.
The communication protocol is: HTTP
The data format is: XML
The specific process is shown in the following figure:
In fact, all we need to do is respond to the HTTP request.
The specific request content is parsed according to the specific XML format, and after processing, it is also returned according to the specific XML format.
All we need is a simple implementation of HttpHandler.
Of course, Wechat platform can also implement more complex businesses, such as Wechat can be used as an embedded browser, we can through the link to Wechat, open the htm interface, and then implement our own logic.
Specific application steps: 1. Register a public account
Registered address: http://mp.weixin.qq.com/
1) first of all, email registration is required:
2) mailbox activation. The mailbox will receive an activation email, just click on the activation link.
3) personal information needs to be registered. Here you need to provide some personal information or unit information.
Now individuals are only allowed to register Subscription account, the company can register the service number, the service number than Subscription account, more functions, can achieve custom menu.
Need to provide information, mainly ID card number, I hold ID card photos, if it is a unit registration, but also need the unit registration number, business license and legal person ID card and photos, feel that this is quite abnormal. Which boss would like you to take a picture of him and his ID card?
Note:
Only two Wechat public platform accounts are allowed to register with the same mobile phone number or the same ID number.
Registration of personal information:
Enterprise user
The above personal information of enterprise users should also be filled in, only the personal information of the operator.
Government media
4) enter the relevant information of public account.
When entering the name and description of the official account, we should note that the name of the public account cannot be edited. Once submitted, it can no longer be changed, so we must be careful.
Registration needs to be reviewed within 7 days. The specific registration steps will not be repeated here.
2. Improve the data
If the audit is approved, we can proceed to the next step. How to bind our service to a public account?
Mainly upload avatars, you can also modify the description information. Note, however, that you can only modify it once a month. So, when doing a new application, be sure to wait until the requirements have been set and UE has designed the icon to deal with it.
If there are any changes, we can only wait a month.
3. Become a developer:
First, turn off the editing mode and turn on the development mode
Here we can really bind our own server.
Bind the service address and token. The server address must be a public network IP, and its port should be 80.
The token value is as complex as possible. Once it is cracked, it is likely to be exploited.
Because the first time you access the server, you need to authenticate, and you need token. And once the verification is successful, it will not be verified in the future.
The public platform message interface provides a new way of message processing for developers.
Message interface (official document) request message interface
Click apply, and fill in the URL url and token, in which token can be entered by the developer to generate a signature.
Web site access
After the user of the public platform submits the information, the Wechat server will send a GET request to the entered URL with four parameters:
Parameter description signature Wechat encryption signature timestamp timestamp nonce random number echostr random string
The developer verifies the request by verifying the signature (there is a verification method below). If it is confirmed that the GET request is from Wechat server, return the echostr parameter content as is, then the access will take effect, otherwise the access will fail.
Signature combines the token parameters entered by the developer with the timestamp parameters and nonce parameters in the request.
Encryption / verification process: 1. The three parameters token, timestamp and nonce are sorted in dictionary order 2. The three parameter strings are concatenated into one string for sha1 encryption 3. The encrypted string obtained by the developer can be compared with signature to identify that the request originated from Wechat message push
When an ordinary Wechat user sends a message to a public account, the Wechat server POST the message to the filled URL. The structure is as follows:
Text message 1348831860 1234567890123456 Parameter description ToUserName developer WeChat FromUserName account (an OpenID) CreateTime message creation time (integer) MsgTypetextContent text message content MsgId message id,64 bit integer picture message 1348831860 1234567890123456 parameter description ToUserName developer WeChat FromUserName account (one OpenID) CreateTime message creation time MsgTypeimagePicUrl picture link MsgId message id 64-bit integer geolocation message 135177636023.134521113.358803201234567890123456 parameter description ToUserName developer WeChat FromUserName account (an OpenID) CreateTime message creation time (integer) MsgTypelocationLocation_X geographic location latitude Location_Y geographic location longitude Scale map zoom size Label geographic location information MsgId message id,64 bit integer link message 13517763601234567890123456 parameter description ToUserName receiver WeChat FromUserName sender WeChat Is an OpenIDCreateTime message creation time MsgType message type, linkTitle message title Description message description Url message link MsgId message id,64 bit integer event push
Event push only supports Wechat version 4.5.Custom menu API for event push, follow and cancel event push is enabled. The rest of the features will be available soon, please look forward to it.
Parameter 123456789 describes the ToUserName receiver's WeChat account FromUserName sender's WeChat. If it is an ordinary user, it is an OpenIDCreateTime message creation time MsgType message type, eventEvent event type, subscribe (subscription), unsubscribe (unsubscribe), CLICK (custom menu click event) EventKey event key value, and message reply corresponding to the key value in the custom menu interface.
For each POST request, the developer returns a specific xml structure in the response package to respond to the message (text, image, voice, video, music are now supported).
The Wechat server will be disconnected if it does not receive a response within five seconds.
The structure of the reply xml is as follows:
Reply text message 12345678 parameter describes ToUserName recipient account (received OpenID) FromUserName developer WeChat message creation time MsgTypetextContent reply message content, length not more than 2048 bytes reply music message 12345678 parameter description ToUserName receiver account (received OpenID) FromUserName developer WeChat CreateTime message creation time MsgTypemusicMusicUrl music link HQMusicUrl high quality music link The WIFI environment gives priority to using this link to play music reply Teletext messages 12345678 2 parameters to describe the ToUserName recipient account (received OpenID) FromUserName developer WeChat CreateTime messages creation time MsgTypenewsArticleCount Teletext messages, which is limited to less than 10 Articles Teletext messages. By default, the first item is large Title Teletext message title Description Teletext message description PicUrl Picture Link, supported JPG, PNG format The better effect is the big picture 640-320 and the small picture 80-80. Url click on the picture and text message to jump to the link notes
1. User OpenID is a fixed and unique string for an official account.
two。 Please use port 80
The above is all the contents of the article "sample Analysis of Wechat Public account Development". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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.