登录服务器,然后从开发=>基本配置:
token是自己设置的,随意设置,
EncodingAESKey是自动随机生成,
然后在入口文件做验证代码:
<?php
/**
* Created by PhpStorm.
* User: lihe
* Date: 17-6-22
* Time: 下午2:26
*/
header('content-type:text');
//timestamp,nonce,signature用$_GET方法获取,
//1.将timestamp,nonce,token按字典序排序
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$token = 'lingsg';
$signature = $_GET['signature'];
$arr = array($timestamp,$nonce,$token);
sort($arr);
$tmpstr = implode('',$arr);
//2.将排序后的三个参数拼接后用sha1加密
$tmpstr = sha1($tmpstr);
//3.将加密后的字符串和signature进行对比,判断该请求是否来自微信标示请求来源于微信
if($tmpstr == $signature) {
ob_clean();
echo $_GET['echostr'];
exit;
}
然后上传到服务器,然后在微信公众号平台选择
兼容模式
提交!提交成功之后,然后启动
配置!注:
header(‘content-type:text’);
ob_clean(); 代码必须存在,避免空格引起的token验证失败