Php version of WeChat public platform developer certification instance

Source: Internet
Author: User
Tags sha1 sha1 encryption

How can the WeChat public platform become a developer?

After logging on to the WeChat public platform, click "Advanced Function =" development mode = "become Developer =" and enter the interface configuration information. Submit the information and wait for our staff to review it.

1. Developer authentication

This is the simplest. The code of the previous ultra-simple version is as follows:

The code is as follows: Copy code

Exit ($ _ GET ['echostr']);

Just write the above sentence in the PHP file. Fill in the token on the WeChat public platform, write the url of the PHP file, and then verify the code. Super simple? Official authentication is not necessary at all, because the signature verification is not used in the subsequent steps, so this place can be easily verified by directly outputting the return value for the convenience of graphs. Of course, the authentication code officially required is also provided below:

The code is as follows: Copy code

$ Token = '11 ';
$ Signarr = array ($ token, $ _ GET ['timestamp'], $ _ GET ['nonce ']);
If ($ this-& gt; signnature ($ signarr, $ _ GET ['signature']) {
Exit ($ _ GET ['echostr']);
Function signnature ($ arr, $ signature ){
Sort ($ arr );
If (sha1 (implode ($ arr) ==$ signature) return true;
Return false;

Save the above code as a php file, set the same token on the WeChat public platform, and then verify the token to pass.

Note: urls can contain get parameters.

Website Access

After the public platform user submits the information, we will request the information to the Url filled in with a GET request with four parameters:

* Signature-WeChat encrypted signature
* Timestamp-timestamp
* Nonce-random number
* Echostr-random string

The developer verifies the validity of website access by verifying signature. If the GET request returns the content of the echostr parameter as is, the access takes effect. Otherwise, the access fails. The verification of signature will be combined with the token parameter and timestamp entered by the developer

Parameters and nonce parameters, encryption process:
* Sort the tokens, timestamp, and nonce in lexicographic order.
* Splice the three parameter strings into one string for sha1 encryption
* The encrypted string obtained by the developer can be compared with signature to identify that the request comes from WeChat.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.