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后没有自动回复,这是为什么?
婚纱影楼小程序提供了一个连接用户与影楼的平台,相当于影楼在微信的官网。它能帮助影楼展示拍摄实力,记录访客数据,宣传优惠活动。使用频率高,方便传播,是影楼在微信端宣传营销的得力助手。功能特点:样片页是影楼展示优秀摄影样片提供给用户欣赏并且吸引客户的。套系页是影楼根据市场需求推出的不同套餐,用户可以按照自己的喜好预定套系。个人中心可以查看用户预约的拍摄计划,也可以获取到影楼的联系方式。
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号