公众号的TOKEN配置PHP代码

1、在后台添加好URL和TOKEN和生成43位随机码  注意域名URL需要备案

2、上传到服务器

3、公众号后台要点提交即可

error_reporting(0);
$signature=$_REQUEST["signature"];
$timestamp= $_REQUEST["timestamp"];
$nonce=$_REQUEST["nonce"];
$echostr=$_REQUEST['echostr'];
$token='shenbaoyuan';//自定义token,公众号后台一样


$arr=array($token,$timestamp,$nonce);
sort($arr,SORT_STRING);//排序
$str=implode($arr);
$str=sha1($str);
if($str==$signature)
{
    ob_clean();
    echo $echostr;
    exit;
}
else
{
    echo '失败';

}

原文地址:https://www.cnblogs.com/bk7788/p/6698428.html