WeChat public platform API

Source: Internet
Author: User
Tags sha1 encryption
Provides various official and user-released code examples. For code reference, you are welcome to learn more about public platform interface APIs, including almost all interfaces, interface call methods, and return codes.
Function checkSignature ($ token ){
/* Obtain the sending confirmation parameters. */
$ Signature = $ _ GET ['signature'];/* the encrypted signature. signature combines the token parameter entered by the developer with the timestamp parameter and nonce parameter in the request. */
$ Timestamp = $ _ GET ['timestamp'];/* timestamp */
$ Nonce = $ _ GET ['nonce '];/* Random Number */
$ Echostr = $ _ GET ['echostr'];/* random string */
/* Encryption/verification process */
/* 1. Sort the tokens, timestamp, and nonce in Lexicographic Order */
$ Array = array ($ token, $ timestamp, $ nonce );
Sort ($ array, SORT_STRING );
/* 2. splice the three parameter strings into one string for sha1 encryption */
$ Str = sha1 (implode ($ array ));
/* 3. The encrypted string obtained by the developer can be compared with signature to identify that the request comes from */
If ($ str ==$ signature & $ echostr ){
Return ture;
} Else {
Return false;
}
}

WeChat.zip (15.99 KB download: 179 times)

AD: truly free, domain name + VM + enterprise mailbox = 0 RMB

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.