public function indexAction() {
//获得几个参数
$token = 'weixin';//此处填写之前开发者配置的token
$nonce = $_GET['nonce'];
$timestamp = $_GET['timestamp'];
$echostr = $_GET['echostr'];
$signature = $_GET['signature'];
//参数字典序排序
$array = array();
$array = array($nonce, $timestamp, $token);
sort($array);
//验证
$str = sha1( implode( $array ) );//sha1加密
//对比验证处理好的str与signature,若确认此次GET请求来自微信服务器,请原样返回echostr参数内容,则接入生效,成为开发者成功,否则接入失败。
if( $str == $signature && $echostr ){
echo $echostr;
}
else{
//接入成功后的其他处理
}
}
在index中放入这些数据,只填一个token就可以了