class Wx extends Controller
{
public function index(){
include_once('../extend/php/WXBizMsgCrypt.php');
$get=input('get.');
$data=file_get_contents('php://input');
$dir=ROOT_PATH.'runtime'.DS.'wx'.DS.'123';
if(!is_dir($dir)){
$res=mkdir(iconv("UTF-8", "GBK", $dir),0777,true);
}
file_put_contents ($dir.DS.date('Y-m').".log", date ( "Y-m-d H:i:s" ) . " " . var_export($get,true).var_export($data,true) . "\r\n", FILE_APPEND );
$echostr=$_GET["echostr"];
if (isset($echostr)){
$encodingAesKey = "wrQcZLJ17AAi2Bn4hqlDwHZSIGv9gvHeenoyyo9G4SW";
$token = "123";
$appId = "wxdb5bbadc70158325";
$tmpArr = array($token,$get['timestamp'],$get['nonce']);
sort($tmpArr, SORT_STRING);
$tmpStr = implode($tmpArr);
$tmpStr = sha1($tmpStr);
if($tmpStr==$get['signature']){
echo $echostr;
exit;
}else{
return false;
}
} else {
$this->responseMsg();
}
}
参考这个试试:https://developers.weixin.qq.com/community/develop/doc/000262ad730a68ce158b89af15bc00