public function index() { if (isset($_GET['echostr'])) { //1.将timestamp,nonce,toke按字典顺序排序 $timestamp = $_GET['timestamp']; $nonce = $_GET['nonce']; $token = 'imooc'; $signature = $_GET['signature']; $array = array($timestamp, $nonce, $token); sort($array); //2.将排序后的三个参数拼接之后用sha1加密 //3.将加密后的字符串与signature进行对比,判断该请求是否来自微信 if (sha1(implode('', $array)) == $signature && $_GET['echostr']) { //第一次接入微信api接口的时候 header('content-type:text'); echo $_GET['echostr']; exit; } } else { $this->responseMsg(); } }
微信公众号接受微信端传来的信息并判断
最新推荐文章于 2022-09-02 11:07:03 发布