用户关注接口实现<?php
include './hcWeChat/hcWeChat.php';
/* 消息识别 */
$hcWeChat->getMsg();
if($hcWeChat->msgType == 'event'){
switch($hcWeChat->event){
//关注
case 'subscribe':
//获取用户信息
$user = $hcWeChat->getUser($hcWeChat->openId);
$hcWeChat->reTextMsg($user['nickname'].'您好,感谢关注 ^_^');
break;
//......
}
}
用户取消关注接口实现<?php
include './hcWeChat/hcWeChat.php';
/* 消息识别 */
$hcWeChat->getMsg();
if($hcWeChat->msgType == 'event'){
switch($hcWeChat->event){
//.....
//取消关注
case 'unsubscribe':
file_put_contents('unsub.txt', $hcWeChat->openId.'取消关注');
break;
}
}