微信接口配置

 1 class Wechat
 2 {
 3     public function __construct(){
 4         $this->checkSignature();
 5     }
 6 
 7     private function checkSignature()
 8     {
 9         $signature = $_GET["signature"]; // 加密签名 微信服务器
10         $timestamp = $_GET["timestamp"]; // 时间戳
11         $nonce = $_GET["nonce"]; // 随机数
12         $echostr = $_GET['echostr'];
13 
14         $token = 'zhangxuhui';
15         $tmpArr = array($token, $timestamp, $nonce);
16         sort($tmpArr, SORT_STRING);
17         $tmpStr = implode( $tmpArr );
18         $tmpStr = sha1( $tmpStr );
19 
20         if( $tmpStr == $signature ){
21             echo $echostr;
22         }else{
23             return false;
24         }
25     }
26 
27     public function index(){
28 
29     }
30 }

 

posted @ 2022-03-18 18:54  被水遗忘の鱼  阅读(119)  评论(0编辑  收藏  举报