<?php
define("TOKEN", "weixin");
$wechatObj=new CWeChat();
$wechatObj->valid();
/**
* 定义一个操作微信公众号账户的类
*/
class CWeChat
{
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=TOKEN;
$tmpArr=array($token,$timestamp,$nonce);
sort($tmpArr);
$tmpStr=implode($tmpArr);
$tmpStr=sha1($tmpStr);
if ($tmpStr==$signature) {
return true;
}else{
return false;
}
}
}
?>
微信验证
最新推荐文章于 2025-08-15 13:24:25 发布