企业微信api,企业微信sdk接口「建议收藏」

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

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新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/186896.html原文链接:https://javaforall.net

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


相关推荐

  • CSRF——攻击与防御

    CSRF——攻击与防御

    2021年8月30日
    65
  • Docker镜像自动执行脚本.sh

    Docker镜像自动执行脚本.sh由于博客现在在docker中部署的,每次打包部署,需要停掉旧容器->删除旧容器->删除镜像->将新的jar包打包成镜像->再次运行,每次发布都需要重复的执行此操作,于是想将所有命令写成脚本,jar包上传之后,运行脚本即可。命令:app_name=’java-blog’app_port=’8081’# 停止正在运行的容器echo ‘……stop container……’docker stop ${app_name}# 删除容器echo ‘…..

    2022年6月13日
    189
  • istio简介和基础组件原理(服务网格Service Mesh)

    Istio简介Istio:一个连接,管理和保护微服务的开放平台。按照isito文档中给出的定义:Istio提供一种简单的方式来建立已部署的服务的网络,具备负载均衡,服务到服务认证,监控等等功能,而不需要改动任何服务代码。简单的说,有了Istio,你的服务就不再需要任何微服务开发框架(典型如SpringCloud,Dubbo),也不再需要自己手动实现各种复杂的服务…

    2022年4月4日
    53
  • springBoot讲解,jpa使用,微服务架构,什么是RESTful API?

    springBoot讲解,jpa使用,微服务架构,什么是RESTful API?springBoot讲解,jpa使用,微服务架构,什么是RESTful API?

    2022年4月23日
    50
  • ss端口1080不能用_端口被占用

    ss端口1080不能用_端口被占用问题解决:SSR的1080端口被占用在我的博客故障解决:端口已被占用1080中已经讨论了一些方法,但也不是每次都能成功。对于SSR,我们完全可以换一种思路:既然1080被占用了,那我就换个端口。找到配置文件gui-config.json找到”localPort”:1080,你完全可以换一个端口号,比如”localPort”:12345,保存后重启…

    2022年9月6日
    3
  • 香农编码的matlab实现实验总结_香农编码C语言

    香农编码的matlab实现实验总结_香农编码C语言信息论与编码实验报告院系:哈尔滨理工大学荣成校区专业:电子信息工程学号:姓名:日期:2015年6月16日香农编码信息论与编码第三次实验报告一……四、实验环境MicrosoftWindows7Matlab6.5五、编码程序计算如下信源进行香农编码,并计算编码效率:XPa00.2a10.19a20.18a30.17a40……

    2022年9月10日
    0

发表回复

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

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