你还在怕在网络使用qq不方便而烦恼吗?你还在为用户发的“你好?在吗”而烦恼吗?今天,可风网即可为您解决这些问题---zblog即时消息客服插件上线,本插件采集websocket协议,消息即时送达,可聊天可客服的一款插件,首发优惠三天,机不可失时不再来。
本插件为在zblog中的最终版本,2.0新版本正在开发中... 新版本的后端将不再基于任何cms或框架开发,已购买zblog版本的可免费升级到2.0
功能
客服、私聊、群聊
消息撤回
群管理
群员禁言
支持浏览器通知
网站打开后可主动发送消息给访客
支持用户登录自动加入指定群聊
支持根据关键词自动回复
支持独立客服页
客服离线消息通知 教程
等等等…
演示站:
演示站请咨询客服
提供的接口
前端js接口:
websocket连接之前:
window.chat.plugin.on('websocket.start','yourname',function(){
  console.log('准备连接');//该接口没有传入参数
});websocket连接成功:
window.chat.plugin.on('websocket.open','yourname',function(e,ws){
  console.log(e);//websocket相关信息
  ws.send('test');//创建的websocket对象,示例是向websocket发送个“test”内容
});websocket连接断开:
window.chat.plugin.on('websocket.close','yourname',function(e){
  console.log(e);//websocket相关信息
  console.log('websocket已断开,正在重连...');
});收到websocket服务器发送的消息:
window.chat.plugin.on('websocket.receive','yourname',function(j){
  console.log(j);//收到的消息
});连接成功后向网站报告clientid:
window.chat.plugin.on('websocket.ReportClientID','yourname',function(r){
  console.log(j.userinfo.name); //用户名称
  console.log(j.userinfo.avatar); //用户名称
  console.log(j.chatlist); //会话列表
});删除回调
window.chat.plugin.unbind('websocket.ReportClientID','yourname');请把yourname替换成你独一无二的名称,如果该名称重复,之前添加的回调会被删除。
后端接口:
处理用户发送的消息:可以实现对发送的消息处理后再送达其他用户
//挂载接口,收到消息的接口,可以对消息处理后再送往其它客户端
Add_Filter_Plugin('Filter_Plugin_Chat_Send_Message_Core','yourappid_FunctionName');
function yourappid_FunctionName($api, &$data){
    global $zbp;
    echo '发送者用户ID' . $api->sender->OID;
    echo '发送是客服:' . $api->sender->isServicer?'是':'否';
    echo '接口者用户ID或群ID' . $api->receiver->OID;
    echo '接口者是客服:' . $api->receiver->isServicer?'是':'否';
    if ($api->receiver->MarkType == 'group'){
        echo '群聊名称:' .$api->receiver->Name ;
    }elseif ($api->receiver->MarkType == 'private'){
        echo '当前是私聊';
    }
    echo '发送者是游客' . $api->sender->isGuest?'是':'否';
    echo '接收者是游客' . $api->receiver->isGuest?'是':'否';
    echo '发送的消息内容:' .$data['content']['data'];
    echo '发送的消息类型:' .$data['content']['type']; // 可能是 string html image
    if ($data['content']['type'] == 'string'){
        //如果发送的消息内容为:‘nihao’则自动替换为‘你好’
        $data['content']['data'] = str_reaplce('nihao','你好',$data['content']['data']);
    }
}消息发送后回调:可以实现离线通知等业务
//挂载接口,消息已发送后回调
Add_Filter_Plugin('Filter_Plugin_Chat_Send_Message_Succeed','yourappid_FunctionName');
function yourappid_FunctionName($api, $data){
    global $zbp;
    echo '发送者用户ID' . $api->sender->OID;
    echo '发送是客服:' . $api->sender->isServicer?'是':'否';
    echo '接口者用户ID或群ID' . $api->receiver->OID;
    echo '接口者是客服:' . $api->receiver->isServicer?'是':'否';
    if ($api->receiver->MarkType == 'group'){
        echo '群聊名称:' .$api->receiver->Name ;
    }elseif ($api->receiver->MarkType == 'private'){
        echo '当前是私聊';
    }
    echo '发送者是游客' . $api->sender->isGuest?'是':'';
    echo '接收者是游客' . $api->receiver->isGuest?'是':'';
    echo '发送的消息内容:' .$data['content']['data'];
    echo '发送的消息类型:' .$data['content']['type']; // 可能是 string html image
    // 自动回复个可以使用html代码的消息
    (new kfuu\plugin\chat\api($api->receiver, $api->sender))->SendMessage('自动回复的消息<br>这是html内容', 'html');
    // 自动回复普通文本消息
    (new kfuu\plugin\chat\api($api->receiver, $api->sender))->SendMessage('自动回复的消息', 'string');
    // 自动回复个图片
    (new kfuu\plugin\chat\api($api->receiver, $api->sender))->SendMessage('https://kfuu.cn/test.jpg', 'image');
    //如果是给客服发送消息,并且客服不在线
    if ($api->receiver->isServicer && !$api->receiver->isOnline){
        echo $data['content']['data']; //消息内容
        //向发送者反馈个系统消息
        $api->PushSystemInfo('客服离线,已成功为您推送离线消息,请耐心等待回复');
    }
}new kfuu\plugin\chat\api 类专门用于发送消息,可以在你插件或主题后端代码中任意地方调用。
参数一:用户ID或者聊天插件中的用户对象
参数一:用户ID或群聊ID或插件中的用户对象
请使用 try catch 捕捉错误

            
                                