微信开发接口配置

Posted on 2022-01-06 10:28  君子不卿  阅读(46)  评论(0)    收藏  举报
<?php
declare (strict_types = 1);

namespace app\index\controller;

class Wechat
{
    public function __construct(){
        $this->checkSignature();
    }
    private function checkSignature()
    {
        $signature = $_GET["signature"]; // 加密签名 微信服务器
        $timestamp = $_GET["timestamp"]; // 时间戳
        $nonce = $_GET["nonce"]; // 随机数
        $echostr = $_GET['echostr'];

        $token = 'php';
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode( $tmpArr );
        $tmpStr = sha1( $tmpStr );

        if( $tmpStr == $signature ){
            echo $echostr;
        }else{
            return false;
        }
    }
    public function index(){
    }
}

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3

//评论