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