define("token", "leo2012");
$wechatobj = new test;
if (isset($_get['echostr'])) {
$wechatobj->valid();
}else{
$wechatobj->responsemsg();
}
class test
{
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;
}
}
public function responsemsg()
{
$poststr = $globals["http_raw_post_data"];
if (!empty($poststr)){
$postobj = simplexml_load_string($poststr, 'simplexmlelement', libxml_nocdata);
$fromusername = $postobj->fromusername;
$tousername = $postobj->tousername;
$keyword = trim($postobj->content);
$time = time();
$texttpl = "
if($keyword == "qqq" || $keyword == "ccc")
{
$msgtype = "text";
$contentstr = date("y-m-d h:i:s",time())."aaaaa";
$resultstr = sprintf($texttpl, $fromusername, $tousername, $time, $msgtype, $contentstr);
echo $resultstr;
}
}else{
echo "";
exit;
}
}
}
?>
上面是代码,输入ccc或qqq后没有自动回复,这是为什么?
AS系统本次的主要更新和新开发的功能如下(暂不详述): 1、修复了普及版的一些大大小小的BUG 2、重新规划整个后台,使后台更加个性化、智能化、更加易用 3、重写了广告部分模块,使其更加专业化 4、重写了文章采集模块,添加了定时自动采集功能 5、添加了供求信息采集功能 6、重写了友情连接功能(原来的太简单了) 8、重写了生成HTML模块。(几个主要模块首页不用原来的生成方式,不再会被卡巴斯机杀毒软
0
你在else下面的echo 输出一个字符串调试就明白了。
$wechatObj->valid();
}else{
$wechatObj->responseMsg();
}
class Test {}
兄弟! 你这个程序在哪里copy的,能不能仔细的看看 你的微信类和测试类 是什么鬼。。。。。。。。两个类都不一样 你怎么调方法
我看错了 不好意思 是我没仔细看。。。。。。。
微信是一款手机通信软件,支持通过手机网络发送语音短信、视频、图片和文字。微信可以单聊及群聊,还能根据地理位置找到附近的人,带给大家全新的移动沟通体验,有需要的小伙伴快来保存下载体验吧!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号