Exemplo n.º 1
0
        break;
    case 'location':
        $content = json_encode($weixin->getRev()->getRevGeo());
        $reMsg = "您所在的位置很安全!";
        break;
    default:
        $reMsg = $weixinconfig['help'];
}
$api->saveMsg($content, $wxid, $type);
if ($reMsg) {
    echo $weixin->text($reMsg)->reply();
    exit;
}
$followInfo = $api->getFollowUserInfo($wxid);
if (!$followInfo or $followInfo['expire_in'] - 86400 < time()) {
    $info = $weixin->getUserInfo($wxid);
    if ($info) {
        $api->followUser($wxid, $info);
    }
}
if ($event['event'] == "subscribe") {
    //用户关注
    if (intval($followInfo['ecuid']) == 0 && $weixinconfig['reg_type'] == 1) {
        $username = $username ? $username : "******" . date('md') . mt_rand(1, 99999);
        $pwd = mt_rand(100000, 999999);
        $rs = $api->bindUser($wxid, $username . '@163.com', $pwd, $username);
        if ($rs === false) {
            echo $weixin->text("系统出错了")->reply();
            exit;
        }
        $weixinconfig['followmsg'] .= "\r\n系统已经为您自动注册并绑定了帐号:{$username} 密码:{$pwd}\r\n";