In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to access Wechat public platform development, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to know about it.
Step 1: fill in the server configuration
After logging in to the official website of Wechat public platform, on the backend management page-developer Center page of the public platform, click the "modify configuration" button and enter the server address (URL), Token and EncodingAESKey, where URL is the interface URL that developers use to receive Wechat messages and events. The Token can be entered by the developer as a signature (the Token is compared with the Token contained in the API URL to verify the security). EncodingAESKey is manually filled in or randomly generated by developers and will be used as the encryption and decryption key of the message body.
At the same time, developers can choose message encryption and decryption methods: plaintext mode, compatibility mode and security mode. The mode selection and server configuration will take effect immediately after submission. Please fill in and choose carefully. The default state of encryption and decryption is plaintext mode. To select compatibility mode and security mode, you need to configure the relevant encryption and decryption code in advance. For more information, please refer to the document of message body signature and encryption and decryption section.
Step 2: verify the validity of the server address
After the developer submits the information, the Wechat server will send a GET request to the entered server address URL. The GET request takes four parameters:
The developer verifies the request by verifying the signature (there is a verification method below). If you confirm that the GET request is from Wechat server and return the echostr parameter content as is, the connection will take effect and become a successful developer, otherwise the connection will fail.
The encryption / verification process is as follows:
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, indicating that the request originated from Wechat
Verify the PHP sample code for signature:
Private function checkSignature () {$signature = $_ GET ["signature"]; $timestamp = $_ GET ["timestamp"]; $nonce = $_ GET ["nonce"]; $token = TOKEN;$tmpArr = array ($token, $timestamp, $nonce); sort ($tmpArr, SORT_STRING); $tmpStr = implode ($tmpArr); $tmpStr = sha1 ($tmpStr); if ($tmpStr = $signature) {return true;} else {return false;}}
Step 3: implement the business logic according to the interface document
After verifying the validity of URL, the connection takes effect and becomes a developer. If the official account type is a service number (Subscription account can only use ordinary message APIs), you can apply for authentication in the public platform website. The service number with successful verification will be granted a large number of API permissions to meet the needs of developers.
Every time a user sends a message to the official account or generates a custom menu click event, the server configuration URL entered by the developer will get the message and event pushed from the Wechat server, and then the developer can respond according to his own business logic, such as a reply message.
When the official account calls each API, it will generally get the correct result. For the specific results, please see the description of the corresponding API. When an error is returned, you can query the cause of the error according to the return code. Global return code description
When the user sends a message to the official account, the sender of the message received by the public account is an OpenID, which is the result of encryption using the user's WeChat account, and each user has a unique OpenID for each official account.
In addition, due to the need for developers to share user accounts among multiple platforms (mobile applications, websites, public accounts) and to unify the account system, Wechat Open platform (open.weixin.qq.com) provides UnionID mechanism. Developers can obtain basic user information through OpenID, and if developers have multiple applications (mobile applications, website applications and public accounts, which will not obtain UnionID until they are bound to the Wechat open platform account), they can distinguish the uniqueness of users by obtaining the UnionID in the user's basic information, because as long as they are mobile applications, website applications and public accounts under the same Wechat open platform account. The user's UnionID is unique. In other words, the same user, for different applications under the same Wechat open platform account, UnionID is the same. For more information, please see the Resource Center of Wechat Open platform-Mobile Application Development-Wechat login-guidelines for calling authorized relationship APIs-obtaining users' personal information (UnionID mechanism).
Thank you for reading this article carefully. I hope the article "how to access Wechat Public platform Development" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.