Пример #1
0
function normalReply($weixin, $msg)
{
    if ($msg['MsgType'] == 'voice') {
        sendKFMessage($msg['FromUserName'], '已为您接入人工客服,请稍候');
        $weixin->toKFMsg();
        updateWechatMode($msg['from'], 'kf');
    } elseif ($msg['MsgType'] == 'img') {
        //         mylog('type:'.$msg['MsgType']);
        //         $weixin->replyText('你好');
    } else {
        $content = $msg['content'];
        if (preg_match('/^dy[0-9]\\d*$/', $content)) {
            $weixin->replyText(expressQuery($msg, $content));
        }
    }
}
Пример #2
0
$myHandler = new interfaceHandler(WEIXIN_ID);
$weixin->valid();
$msg = $weixin->receiverFilter();
$random = rand(1000, 9999);
//mylog(getArrayInf($msg));
if (in_array($msg['MsgType'], array('text', 'voice', 'img'))) {
    //    mylog('inarray');
    $mode = getWechatMode($msg['from']);
    //    mylog($mode);
    switch ($mode) {
        case 'normal':
            normalReply($weixin, $msg);
            break;
        case 'kf':
            $weixin->toKFMsg();
            sendKFMessage($msg['from'], '您好,有什么可以帮助您?');
            break;
    }
}
if ($msg['MsgType'] == 'event') {
    include_once 'event.php';
    if (in_array($msg['Event'], array('VIEW', 'kf_create_session', 'kf_close_session'))) {
        $msg['Event']($msg);
    }
}
echo 'success';
exit;
//$t='您现在访问的是一个演示电商型微网站的公众号,商城内的商品仅供展示,其显示的售价不能作为商品实际价格的参考依据';
//$to=$msg['FromUserName'];
//if($msg['content']=='网店'){
////        sendTemplateManage($to,'oMhzLlRCMJ_vXQKQL9Yx12DsG8fXlIUzcz0qz4kb9SI','http://www.qq.com',$tmpmsg);
Пример #3
0
function linkKf($openId, $kf = 'default', $remark = '用户从网页接入')
{
    //    $inf=getOnlineKfList();
    //    $inf=json_decode($inf,true);
    $return = 0;
    if ($kfAc = chooseKF($kf)) {
        $request = connectKF($openId, $kfAc, $remark);
        $request = json_decode($request, true);
        if ($request['errcode'] == 0) {
            sendKFMessage($openId, '已为您接入人工客服,请稍候');
            $return = 0;
        } else {
            sendKFMessage($openId, '客服不在线或者忙碌中,请稍候再试');
            $return = 1;
        }
    } else {
        sendKFMessage($openId, '当前无在线客服,请稍候再试');
        $return = 2;
    }
    return $return;
}
Пример #4
0
    }
    if (isset($_GET['getOrderDetail'])) {
        $orderQuery = pdoQuery('order_view', null, array("id" => $_GET['id']), ' limit 1');
        $order_inf = $orderQuery->fetch();
        $ordeDetailQuery = pdoQuery('user_order_view', null, array('o_id' => $_GET['id']), ' order by price desc');
        include 'view/order_detail.html.php';
        exit;
    }
    if (isset($_GET['getFav'])) {
        $query = pdoQuery('user_fav_view', null, array('c_id' => $_SESSION['customerId']), ' group by g_id');
        include 'view/favorite.html.php';
        exit;
    }
    if (isset($_GET['linkKf'])) {
        include_once $GLOBALS['mypath'] . '/wechat/serveManager.php';
        $respon = sendKFMessage($_SESSION['customerId'], '您好' . $_SESSION['userInf']['nickname'] . ',有什么可以帮助你?');
        header('location:index.php?rand=' . $_SESSION['rand']);
        exit;
    }
}
//以下功能不需登录,不需判断$_SESSION['customerId']
if (isset($_GET['oauth'])) {
    include_once $GLOBALS['mypath'] . '/wechat/serveManager.php';
    if ($_GET['code']) {
        //        mylog('getCode');
        $userId = getOauthToken($_GET['code']);
        //        mylog('getOpenId'.$userId['openid']);
        $_SESSION['customerId'] = $userId['openid'];
        $_SESSION['userInf'] = getUnionId($userId['openid']);
    } else {
        mylog('cannot get Code');