微信api 关注事件

<?php
header('Content-type: text/html; charset=utf-8');#设置头信息
require_once('zhphpWeixinApi.class.php');#加载微信接口类文件
$zhwx=new zhphpWeixinApi();//实例化
$configArr=array(
				'token'=>'wxtest1',
				'appid'=>'wx5b79a26868798826',
				'appSecret'=>'a95952819cc768fc130bc0cc0444ae77',
				'myweixinId'=>'gh_746ed5c6a58b'
				);
$zhwx->setConfig($configArr);//配置文件
if($zhwx->validToken()){
	if($zhwx->weixinBaseApiMessage()){
		$keyword=$zhwx->getUserTextRequest();//得到用户发的微信内容
		$msgtype=$zhwx->getUserMsgType();//得到用户发的微信数据类型
		$SendTime=$zhwx->getUserSendTime();//得到用户发送的时间
		 if($msgtype == 'event'){
			 $content='';
			 $content='感谢您关注Zhphp官方微信平台,'."\n";
			 $content.='我们的微信号是:echozhphp'."\n";
			 $content.='^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^';
			  //把数据放进去,由系统自动检验类型,
			 //并返回字符串或者数组的结果
			 $callData=$zhwx->responseEventMessage($content);
			 $zhwx->responseMessage('text',$callData); //使用数据
			}
	}
}

发布了186 篇原创文章 · 获赞 24 · 访问量 31万+

猜你喜欢

转载自blog.csdn.net/echocdzh/article/details/50699774