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


相关推荐

  • 2014年国人开发的最热门的开源软件TOP 100

    2014年国人开发的最热门的开源软件TOP 100

    2021年9月30日
    33
  • 家庭影院.液晶电视.液晶电视连接电脑全功略续[通俗易懂]

    家庭影院.液晶电视.液晶电视连接电脑全功略续[通俗易懂]家庭影院.液晶电视.液晶电视连接电脑全功略续草木瓜20090201一、前言 《家庭影院.液晶电视.液晶电视连接电脑全功略》http://blog.csdn.net/liwei_cmg/archive/2008/11/28/3402883.aspx 一文中介绍了使用三星32A550P1R,作为电脑外接显示器+音箱的方法。其中中提到了 使用1366*768的分辨率。32A550物理

    2022年10月19日
    1
  • Spring IOC容器的初始化过程

    Spring IOC容器的初始化过程Spring IOC容器的初始化过程

    2022年6月24日
    26
  • idea激活码2021.12【2021最新】

    (idea激活码2021.12)最近有小伙伴私信我,问我这边有没有免费的intellijIdea的激活码,然后我将全栈君台教程分享给他了。激活成功之后他一直表示感谢,哈哈~IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.htmlFN…

    2022年3月30日
    55
  • 4g网络怎么设置网速更快(移动4g网速慢怎么办)

    转载自品略图书馆http://www.pinlue.com/article/2020/05/1618/5110522403532.html别人是4G网,你也是4G网,你却更慢,不妨这样设置,网速飞快提升随着5G网络的走近,人们越来越期待未来的生活,以后电视上电影里面不可能实现的在现实中可能都会实现,5G网络的到来,人们的生活又会有怎样翻天覆地的变化,不过现在5G网络还没有正式运用,可能要到明年才能正式普及,所大家手中用的手机都是搭载4G网络,而有人发现,别人是4G网,你也是4G网,你却更慢,不妨这.

    2022年4月12日
    109
  • 四个c语言小游戏

    四个c语言小游戏C语言小游戏0、前言1、普普通通的五子棋2、好难操作的贪吃蛇3、简单到炸的自制迷宫4、不忍直视的双人飞机对战0、前言1、我使用的是编译软件是vc6.02、如果代码无法运行,你可以尝试吧文件xxx.c改为xxx.cpp3、四个小游戏我都运行过,确保是可以运行的。虽然可玩性、操作性。。。1、普普通通的五子棋这是四个游戏中,个人感觉最好的一个了。#include<stdio.h>#include<windows.h>#include<time.h>#i

    2022年5月19日
    382

发表回复

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

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