<?php
class demo{
public function index(){
//验证消息来自微信服务器
//1.将token , timestamp, nonce三个参数进行字典排序
$token = 'weixin'; //token和配置的一样
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$arr = array($token,$timestamp,$nonce);
sort($arr);
//2.拼接起来 sha1加密
$str = sha1(implode('', $arr));
//3.获得加密后与signatrue对比
if($str == $_GET['signature'] && $_GET['echostr']){
echo $_GET['echostr'];
exit;
}else{
$this->responsEvent();
}
}
}
$demo = new demo();
$demo->index();
class demo{
public function index(){
//验证消息来自微信服务器
//1.将token , timestamp, nonce三个参数进行字典排序
$token = 'weixin'; //token和配置的一样
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$arr = array($token,$timestamp,$nonce);
sort($arr);
//2.拼接起来 sha1加密
$str = sha1(implode('', $arr));
//3.获得加密后与signatrue对比
if($str == $_GET['signature'] && $_GET['echostr']){
echo $_GET['echostr'];
exit;
}else{
$this->responsEvent();
}
}
}
$demo = new demo();
$demo->index();
?>
将代码放入,你配置的url服务器中,,