企业微信api接口,企业微信sdk

企业微信api接口,企业微信sdk企业微信api接口,企业微信sdk1、企业微信SDK接口API调用-企业微信好友收发消息/***给企业微信好友发消息*@authorwechat:happybabby110*@bloghttp://www.wlkankan.cn*/@AsyncpublicvoidhandleMsg(ChannelHandlerContextctx,TransportMessagevo,StringcontentJ…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

企业微信api接口,企业微信sdk

1、企业微信SDK接口API调用-企业微信好友收发消息  

    /**
     * 给企业微信好友发消息
     * @author wechat:happybabby110
     * @blog http://www.wlkankan.cn
     */
    @Async
    public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo, String contentJsonStr) {

        try {

            log.debug(contentJsonStr);
            TalkToFriendTaskMessage.Builder bd = TalkToFriendTaskMessage.newBuilder();
            JsonFormat.parser().merge(contentJsonStr, bd);
            TalkToFriendTaskMessage req = bd.build();
        
            // 将消息转发送给手机客户端
            asyncTaskService.msgSend2Phone(ctx, String.valueOf(req.getWxId()), EnumMsgType.TalkToFriendTask, vo, req);

        } catch (Exception e) {

            e.printStackTrace();
            MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
        }
    }

    /**
     * 企业微信好友发来聊天消息
     * @author wechat:happybabby110
     * @blog http://www.wlkankan.cn
     */
    @Async
    public void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {

        try {

            FriendTalkNoticeMessage req = vo.getContent().unpack(FriendTalkNoticeMessage.class);
            log.debug(JsonFormat.printer().print(req));
            
            log.debug(LocalDateTime.now()+” 微信好友发来聊天消息  对应的线程名: “+Thread.currentThread().getName());
               
            //消息转发到pc端
            asyncTaskService.msgSend2pc(String.valueOf(req.getWxId()), EnumMsgType.FriendTalkNotice, req);
             
            // 告诉客户端消息已收到
            MessageUtil.sendMsg(ctx, EnumMsgType.MsgReceivedAck, vo.getAccessToken(), vo.getId(), null);
             
        } catch (Exception e) {

            e.printStackTrace();
            MessageUtil.sendErrMsg(ctx, EnumErrorCode.InvalidParam,vo.getId(), e.getMessage());
        }
    }

2、企业微信SDK接口API调用-通过手机号或微信好友添加客户

    /** 
     * 企业微信搜索手机号添加微信
     * @author wechat:happybabby110
     * @blog http://www.wlkankan.cn
     */
 
    public  void handleMsg(ChannelHandlerContext ctx ,TransportMessage vo, String contentJsonStr) {

        try {

            log.debug(contentJsonStr);
            AddCustomerFromSearchTaskMessage.Builder bd = AddCustomerFromSearchTaskMessage.newBuilder();
            JsonFormat.parser().merge(contentJsonStr, bd);
            AddCustomerFromSearchTaskMessage req = bd.build();
        
            // 将消息转发送给手机客户端
            asyncTaskService.msgSend2Phone(ctx, String.valueOf(req.getWxId()), EnumMsgType.AddCustomerFromSearchTask, vo, req);

        } catch (Exception e) {

            e.printStackTrace();
            MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
        }
    }
   

    /** 
     * 从企业微信好友中添加客户
     * @author wechat:happybabby110
     * @blog http://www.wlkankan.cn
     */
 
    public  void handleMsg(ChannelHandlerContext ctx ,TransportMessage vo, String contentJsonStr) {

        try {

            log.debug(contentJsonStr);
            AddCustomerFromWxTaskMessage.Builder bd = AddCustomerFromWxTaskMessage.newBuilder();
            JsonFormat.parser().merge(contentJsonStr, bd);
            AddCustomerFromWxTaskMessage req = bd.build();
        
            // 将消息转发送给手机客户端
            asyncTaskService.msgSend2Phone(ctx, String.valueOf(req.getWxId()), EnumMsgType.AddCustomerFromWxTask, vo, req);

        } catch (Exception e) {

            e.printStackTrace();
            MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
        }
    }

3、企业微信SDK接口API调用-触发企业微信推送联系人列表

    /**
     * 触发推送企业微信联系人列表任务
     * @author wechat:happybabby110
     * @blog http://www.wlkankan.cn
     */
    @Async
    public  void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {

        try {

            log.debug(contentJsonStr);
            CommonTriggerTaskMessage.Builder bd = CommonTriggerTaskMessage.newBuilder();
            JsonFormat.parser().merge(contentJsonStr, bd);
            CommonTriggerTaskMessage req = bd.build();
             
            //将消息转发送给手机客户端
            asyncTaskService.msgSend2Phone(ctx, String.valueOf(req.getWxId()), EnumMsgType.TriggerContactPushTask, vo, req);
        } catch (Exception e) {

            e.printStackTrace();
            MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
        }
    }

    /**
     * 企业微信推送联系人列表
     * @author wechat:happybabby110
     * @blog http://www.wlkankan.cn
     */
    @Async
    public  void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {

        try {

            ContactPushNoticeMessage req = vo.getContent().unpack(ContactPushNoticeMessage.class);
            log.debug(JsonFormat.printer().print(req)); 
        
            asyncTaskService.msgSend2pc(String.valueOf(req.getWxId()), EnumMsgType.ContactPushNotice, 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);
        }
    }

 

4、企业微信SDK接口API调用-触发企业微信推送会话列表

   /**
     * 触发企业微信推送会话列表任务
     * @author wechat:happybabby110
     * @blog http://www.wlkankan.cn
     */
    @Async
    public  void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {

        try {

            log.debug(contentJsonStr);
            CommonTriggerTaskMessage.Builder bd = CommonTriggerTaskMessage.newBuilder();
            JsonFormat.parser().merge(contentJsonStr, bd);
            CommonTriggerTaskMessage req = bd.build();
             
            //将消息转发送给手机客户端
            asyncTaskService.msgSend2Phone(ctx, String.valueOf(req.getWxId()), EnumMsgType.TriggerConversationPushTask, vo, req);
        } catch (Exception e) {

            e.printStackTrace();
            MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
        }
    }

   /**
     * 企业微信聊天会话列表推送 
     * @author wechat:happybabby110
     * @blog http://www.wlkankan.cn
     */
    @Async
    public  void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {

        try {

            ConversationPushNoticeMessage req = vo.getContent().unpack(ConversationPushNoticeMessage.class);
            log.debug(JsonFormat.printer().print(req)); 
        
            asyncTaskService.msgSend2pc(String.valueOf(req.getWxId()), EnumMsgType.ConversationPushNotice, 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);
        }
    }

 

5、企业微信SDK接口API调用-触发推送企业微信微信好友

   /**
     * 触发企业微信推送微信好友列表
     * @author wechat:happybabby110
     * @blog http://www.wlkankan.cn
     */
    @Async
    public  void handleMsg(ChannelHandlerContext ctx,TransportMessage vo, String contentJsonStr) {

        try {

            log.debug(contentJsonStr);
            CommonTriggerTaskMessage.Builder bd = CommonTriggerTaskMessage.newBuilder();
            JsonFormat.parser().merge(contentJsonStr, bd);
            CommonTriggerTaskMessage req = bd.build();
             
            //将消息转发送给手机客户端
            asyncTaskService.msgSend2Phone(ctx, String.valueOf(req.getWxId()), EnumMsgType.TriggerWechatFriendPushTask, vo, req);
        } catch (Exception e) {

            e.printStackTrace();
            MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
        }
    }

   /**
     * 企业微信好友列表推送,用于从微信好友中添加客户
     * @author wechat:happybabby110
     * @blog http://www.wlkankan.cn
     */
    @Async
    public  void handleMsg(ChannelHandlerContext ctx, TransportMessage vo) {

        try {

            WxFriendPushNoticeMessage req = vo.getContent().unpack(WxFriendPushNoticeMessage.class);
            log.debug(JsonFormat.printer().print(req)); 
        
            asyncTaskService.msgSend2pc(String.valueOf(req.getWxId()), EnumMsgType.WxFriendPushNotice, 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);
        }
    }

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/186599.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 如何使用eclipse创建JAVA项目并写一个简单的HelloWorld

    如何使用eclipse创建JAVA项目并写一个简单的HelloWorld打开eclipse软件,选择好工作区域(就是项目的储存地址)后登陆。File-New-Project选择JavaProject输入项目名称点击完成(Finish)在SRC(SRC是专门放java源代码的文件夹,就是你在IDE里编写的各个java类的文件都在里面)中新建package包包的命名规范:包名全部使用小写。包名通常由若干个标识符…

    2022年7月24日
    7
  • 元素守恒计算方法_树状数组求逆序对

    元素守恒计算方法_树状数组求逆序对给定一个整数数组 nums,按要求返回一个新数组 counts。数组 counts 有该性质: counts[i] 的值是 nums[i] 右侧小于 nums[i] 的元素的数量。示例:输入:nums = [5,2,6,1]输出:[2,1,1,0] 解释:5 的右侧有 2 个更小的元素 (2 和 1)2 的右侧仅有 1 个更小的元素 (1)6 的右侧有 1 个更小的元素 (1)1 的右侧有 0 个更小的元素提示:0 <= nums.length <= 10^5-10^4

    2022年8月9日
    7
  • μC/OS之OSTaskCreate()[通俗易懂]

    μC/OS之OSTaskCreate()[通俗易懂]转自 http://blog.csdn.net/xiaocaichonga/article/details/7449409建立任务OSTaskCreate()1.OSTaskCreate()函数的声明  INT8UOSTaskCreate(void(*task)(void*pd),void*pdata,OS_STK*ptos,INT8Uprio)   1.1返

    2022年9月6日
    5
  • 数据库期末考试复习题 第二�

    数据库期末考试复习题 第二�

    2021年11月14日
    39
  • 防火墙透明模式和路由模式区别_防火墙的部署模式

    防火墙透明模式和路由模式区别_防火墙的部署模式防火墙能够工作在三种模式下:路由模式、透明模式、混合模式。如果防火墙以第三层对外连接(接口具有IP地址),则认为防火墙工作在路由模式下;若防火墙通过第二层对外连接(接口无IP地址),则防火墙工作在透明模式下;若防火墙同时具有工作在路由模式和透明模式的接口(某些接口具有IP地址,某些接口无IP地址),则防火墙工作在混合模式下。防火墙三种工作模式的简介1、路由模式当防火墙位于内部网络和外部网络之间时,需要将防火墙与内部网络、外部网络以及DMZ三个区域相连的接口分别配置成不同网段的IP地址

    2025年8月10日
    0
  • Android适应方案汇总(三)

    Android适应方案汇总(三)

    2022年1月1日
    55

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号