企业微信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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Pycharm中的terminal无法使用bash命令解决办法

    Pycharm中的terminal无法使用bash命令解决办法Reason:最近在看FADA论文,并且要运行代码。要运行的文件是sh文件,我想在terminal中使用bashxxx.sh来运行此文件,结果报错:‘bash’不是内部或外部命令,也不是可运行的程序或批处理文件。解决办法:(需要提前下好git,git网上教程很多,这里不赘述)打开Pycharm,File—->Settings—–>Tools—–>Terminal,如下图选择git安装目录下,bin文件中的bash.exe即可点击OK之后,去Terminal中看,

    2025年7月3日
    2
  • PathFileExists用法--使用#include <shlwapi.h>

    PathFileExists用法--使用#include <shlwapi.h>BOOLPathFileExists(LPCTSTRpszPath);Determinesifafileexists.—经检测,该函数可以检测文件或目录是否存在!RemarksThisfunctionteststhevalidityofthefileandpath.Itworksonlyonthelocal…

    2022年7月12日
    14
  • SVN的安装与配置

    SVN的安装与配置本文主要介绍windows与阿里云liunx(centos)的安装与配置SVN工作原理:客户端-服务端代码的提交、更新每一个版本都会在svn的安装配置目录下SVN下载地址:http://subv

    2022年7月2日
    28
  • python流程控制

    流程控制概念什么是流程控制?关于声明式编程语言和函数式编程语言详解以上是官方的解释,我们列举一个现实中的实例来具体说明一下Python的条件和循环语句,决定了程序的控制流程,体现结构的多样性。

    2022年3月29日
    52
  • 图像处理的Dither和Banding「建议收藏」

    图像处理的Dither和Banding「建议收藏」由于前面的文章涉及到了这两个概念,而我又对图像处理一窍不通,所以专门写一篇文章来了解这两个概念。Colourbanding       banding是计算机图形中颜色表现不精确的一个问题。DitherDither(抖动)是一种故意造成的噪音用以随机化量化误差,阻止大幅度拉升图像时导致的像banding(色带)这样的问题.Dither概念常用在

    2022年10月13日
    1
  • gbk的不可映射字符_编码gb18030的不可映射字符

    gbk的不可映射字符_编码gb18030的不可映射字符当我们需要输出中文时,在DOS等运行和调试代码时会出现study01.java:3:错误:编码GBK的不可映射字符System.out.println(“浠婂ぉ鐨勬棩鏈熸槸锛?”+day)锛?^或者中文编码错误原因:WindowsCMD和PowerShell的默认编码格式是GBK(汉字内码扩展规范即国标),而VScode、Notepad++甚至是记事本等编辑器的默认编码格式是UTF-8。解决方法

    2025年8月19日
    0

发表回复

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

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