


Three steps to teach you how to access WeChat public platform development
Step 1: Fill in the server configuration
After logging in to the official website of the WeChat public platform, on the public platform backend management page - Developer Center page, click the "Modify Configuration" button and fill in the server Address (URL), Token and EncodingAESKey, where URL is the interfaceURL used by developers to receive WeChat messages and events. The Token can be filled in by the developer arbitrarily and used to generate a signature (the Token will be compared with the Token contained in the interface URL to verify the security). EncodingAESKey is manually filled in by the developer or randomly generated, and will be used as the message body encryption and decryption key.
At the same time, developers can choose the message encryption and decryption methods: plaintext mode, compatibility mode and security mode. The mode selection and server configuration will take effect immediately after submission. Developers are advised to fill in and select carefully. The default state of the encryption and decryption method is plain text mode. Selecting compatibility mode and security mode requires configuring the relevant encryption and decryption codes in advance. For details, please refer to the documentation of the message body signature and encryption and decryption sections.
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 filled in server address URL , the GET request carries four parameters:
The developer verifies the request by checking the signature (the verification method is below). If it is confirmed that this GET request comes from the WeChat server, please return the echostr parameter content as it is, then the access will take effect and you will become a developer successfully, otherwise the access will fail.
The encryption/verification process is as follows:
1. 将token、timestamp、nonce三个参数进行字典序排序 2. 将三个参数字符串拼接成一个字符串进行sha1加密 3. 开发者获得加密后的字符串可与signature对比,标识该请求来源于微信
PHP sample code for verifying 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; } }
PHP sample code download: Download
Step 3: Implement business logic according to the interface document
After successfully verifying the validity of the URL, the access will take effect and you will become a developer. If the public account type is a service account (subscription accounts can only use ordinary message interfaces), you can apply for certification on the public platform website. The successfully certified service account will obtain many interface permissions to meet the needs of developers.
Every time the user sends a message to the public account or generates a custom menu click event, the server configuration URL filled in by the developer will be pushed by the WeChat server Messages and events, and then developers can respond according to their own business logic, such as replying to messages, etc.
When the public account calls each interface, it will generally obtain the correct result. The specific results can be found in the description of the corresponding interface. When an error is returned, you can querythe cause of the error based on the return code. Global return code description
When a user sends a message to an official account, the sender of the message received by the official account is an OpenID, which is the result of encrypting the user's WeChat account. Each user has an OpenID for each official account. A unique OpenID.
In addition, since developers often need to share user accounts and unify account systems across multiple platforms (mobile applications, websites, public accounts), the WeChat open platform (open.weixin.qq.com) provides UnionID mechanism. Developers can obtain basic user information through OpenID. If the developer has multiple applications (mobile applications, website applications and public accounts, the public account will only obtain the UnionID after it is bound to the WeChat open platform account). The uniqueness of the user can be distinguished by obtaining the UnionID in the user's basic information, because as long as there 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 has the same UnionID for different applications under the same WeChat open platform account. For details, please view the Resource Center of the WeChat Open Platform - Mobile Application Development - WeChat Login - Authorization Relationship Interface Call Guide - Obtaining User Personal Information (UnionID Mechanism).
Please also note that WeChat public account interface only supports interface 80.
【Related Recommendations】
1. Special Recommendation:"php Programmer Toolbox" V0.1 version Download
2. WeChat public account platform source code download
3. Alizi order system source code download
The above is the detailed content of Three steps to teach you how to access WeChat public platform development. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP is an open source scripting language that is widely used in web development and server-side programming, especially in WeChat development. Today, more and more companies and developers are starting to use PHP for WeChat development because it has become a truly easy-to-learn and easy-to-use development language. In WeChat development, message encryption and decryption are a very important issue because they involve data security. For messages without encryption and decryption methods, hackers can easily obtain the data, posing a threat to users.

With the popularity of WeChat, more and more companies are beginning to use it as a marketing tool. The WeChat group messaging function is one of the important means for enterprises to conduct WeChat marketing. However, if you only rely on manual sending, it is an extremely time-consuming and laborious task for marketers. Therefore, it is particularly important to develop a WeChat mass messaging tool. This article will introduce how to use PHP to develop WeChat mass messaging tools. 1. Preparation work To develop WeChat mass messaging tools, we need to master the following technical points: Basic knowledge of PHP WeChat public platform development Development tools: Sub

Honor MagicBook Pro14 is released stunningly, leading the new era of AIPC! On the eve of the opening of MWC, Honor first released the new MagicBook Pro14 notebook in China and simultaneously launched the AIPC 2.0 strategy to comprehensively innovate the laptop experience with AI technology. Honor AIPC2.0 strategy covers AI core-driven intelligent hardware, AI agent-enabled human-computer interaction, and cross-end ecosystem of AI service flow. The highly praised "One Sentence Things" AI interactive experience of Honor mobile phones will also be implemented on MagicBook Pro14, and users can complete the operation with just voice commands. Equipped with the new HONORTurboX technology, MagicBo

In the development of WeChat public accounts, user tag management is a very important function, which allows developers to better understand and manage their users. This article will introduce how to use PHP to implement the WeChat user tag management function. 1. Obtain the openid of the WeChat user. Before using the WeChat user tag management function, we first need to obtain the user's openid. In the development of WeChat public accounts, it is a common practice to obtain openid through user authorization. After the user authorization is completed, we can obtain the user through the following code

Detailed explanation of DeepSeekAPI access and call: Quick Start Guide This article will guide you in detail how to access and call DeepSeekAPI, helping you easily use powerful AI models. Step 1: Get the API key to access the DeepSeek official website and click on the "Open Platform" in the upper right corner. You will get a certain number of free tokens (used to measure API usage). In the menu on the left, click "APIKeys" and then click "Create APIkey". Name your APIkey (for example, "test") and copy the generated key right away. Be sure to save this key properly, as it will only be displayed once

As WeChat becomes an increasingly important communication tool in people's lives, its agile messaging function is quickly favored by a large number of enterprises and individuals. For enterprises, developing WeChat into a marketing platform has become a trend, and the importance of WeChat development has gradually become more prominent. Among them, the group sending function is even more widely used. So, as a PHP programmer, how to implement group message sending records? The following will give you a brief introduction. 1. Understand the development knowledge related to WeChat public accounts. Before understanding how to implement group message sending records, I

WeChat is currently one of the social platforms with the largest user base in the world. With the popularity of mobile Internet, more and more companies are beginning to realize the importance of WeChat marketing. When conducting WeChat marketing, customer service is a crucial part. In order to better manage the customer service chat window, we can use PHP language for WeChat development. 1. Introduction to PHP WeChat development PHP is an open source server-side scripting language that is widely used in the field of Web development. Combined with the development interface provided by WeChat public platform, we can use PHP language to conduct WeChat

In the development of WeChat public accounts, the voting function is often used. The voting function is a great way for users to quickly participate in interactions, and it is also an important tool for holding events and surveying opinions. This article will introduce you how to use PHP to implement WeChat voting function. Obtain the authorization of the WeChat official account. First, you need to obtain the authorization of the WeChat official account. On the WeChat public platform, you need to configure the API address of the WeChat public account, the official account, and the token corresponding to the public account. In the process of our development using PHP language, we need to use the PH officially provided by WeChat
