重構驗證接口python
public function index(){ //得到參數nonce token timestamp echostr signature $nonce = $_GET['nonce']; $token = 'weixin'; $timestamp = $_GET['timestamp']; $echostr = $_GET['echort']; $signature = $_GET['signature']; //造成數組,按字典序排序 $array = array(); $array = array($timestamp,$nonce,$token); sort($array); //拼接成字符串,sha1加密,而後 與signature進行校驗 $str = sha1(implode($array)); if($tmpstr ==$signature ){ echo $_GET['echostr']; exit; } }