微信平臺驗證接口的實現php
- 將timestamp,nonce,token按字典序排序 微信
$timestamp = $_GET['timestamp']; $nonce = $_GET['nonce']; $token = 'weixin'; $signature = $_GET['signature ']; $array = array($timestamp,$nonce,$token); sort($array);//字典序排序
- 將排序後的三個參數拼接以後用sha1加密加密
$tmpstr = imploade(' ',$array);//join,拼接參數 $tmpstr = sha1($tmpstr);
- 將加密後的字符串與signature進行對比,判斷該請求是否來自微信spa
if($tmpstr ==$signature ){ echo $_GET['echostr']; exit; }