<?php
$wechatObj = new wechatCallbackapiTest();
$xml = file_get_contents('php://input','r');
file_put_contents(__DIR__.'/aa.log',$xml ,FILE_APPEND);
if (!isset($_GET['echostr'])) {
echo $wechatObj->responseMsg();
}else{
$wechatObj->valid();
}
class wechatCallbackapiTest
{
public function valid()
{
$echoStr = $_GET["echostr"];
if($this->checkSignature()){
echo $echoStr;
exit;
}
}
private function checkSignature()
{
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token = '123123123';
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature ){
微信发送消息 返回消息代码干货
最新推荐文章于 2024-05-16 02:25:27 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)