快捷搜索:

微信协议接口调用-加微信好友及通过好友请求

微信协议接口调用-加微信好友及通过好友请求

加微信好友

    /** 
     * 微信自动添加好友
     * @author wechatno:tangjinjinwx
     * @blog http://www.wlkankan.cn
     */
    @Async
    public  void handleMsg(ChannelHandlerContext ctx ,TransportMessage vo, String contentJsonStr) {
        try {
            log.debug(contentJsonStr);
            FriendAddTaskSetting  req =  JSON.parseObject(contentJsonStr,FriendAddTaskSetting.class);
            if(null != req){
                friendAddTaskService.savePcTask(req);
                //3、告诉PC客户端消息已收到
                MessageUtil.sendCustomJsonMsg(ctx, "AutoFriendAddTaskResp", resp);
            } 
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
        }
    }

微信协议接口调用-加微信好友及通过好友请求

微信新增好友通知  
    /**
     * 微信新增好友通知
     * @author wechatno:tangjinjinwx
     * @blog http://www.wlkankan.cn
     */
    @Async
    public  void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {
        try {
            FriendAddNoticeMessage req = vo.getContent().unpack(FriendAddNoticeMessage.class);
             
            //把消息转发给pc端
            asyncTaskService.msgSend2pc(req.getWeChatId(), EnumMsgType.FriendAddNotice, req);
            
            //保存新增好友
            asyncTaskService.saveFriendAddContactinfo(req);
            
            //告诉客户端消息已收到
            MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);
        } catch (Exception e) {
            e.printStackTrace();
            MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam,vo.getId(), Constant.ERROR_MSG_DECODFAIL);
        }
    }

以上代码依赖微信开发SDK,微信api接口方案咨询微信happybabby110

微信聚合聊天客服系统--微信SDK方案演示系统

拓展阅读:http://www.wlkankan.cn/cate41/301.html


http://www.yunlauncher.com/files/apk/yyb.apk

http://www.yunlauncher.com/files/apk/360.apk



文章来自:微赚淘客
分享地址:/bbs/cate40/211321.html