您的位置:首页 > 编程语言 > PHP开发

基于zhphpWeixinApi.class.php 实例二,关注事件

2016-09-23 17:28 411 查看
基于zhphpweixin.class.php 实例二,关注事件
<?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); //使用数据
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  实例 php zhphpweixin