<?php //1、將timestamp, nonce, token 按字典序排序 $timestamp = $_GET['timestamp']; $nonce = $_GET['nonce']; $token = 'weixin'; //你在公眾平臺上填寫的token $signature = ...
<?php //1、將timestamp, nonce, token 按字典序排序 $timestamp = $_GET['timestamp']; $nonce = $_GET['nonce']; $token = 'weixin'; //你在公眾平臺上填寫的token $signature = $_GET['signature']; $arr = array( $timestamp, $nonce, $token ); sort($arr); //2、將排序後的3個參數拼接後用sha1加密 $tmpstr = implode('', $arr); $tmpstr = sha1($tmpstr); //3、將加密後的字元串與signature進行對比,判斷該請求是否來自微信 if($tmpstr == $signature){ echo $_GET['echostr']; exit; }