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

简介: 企业微信api接口,企业微信sdk

企业微信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);
        }
    }
相关文章
|
1月前
|
弹性计算 监控 安全
API稳定安全最佳实践:用阿里云SDK为业务保驾护航
阿里云智能集团高级技术专家赵建强和曹佩杰介绍了API稳定安全最佳实践,涵盖业务上云真实案例、集成开发最佳实践、配额管理和共担模型四部分。通过分析企业在不同阶段遇到的问题,如签名报错、异常处理不严谨、扩容失败等,提出了解决方案和工具,确保API调用的安全性和稳定性。特别强调了SDK的使用、无AK方案、自动刷新机制以及配额中心的作用,帮助用户构建更稳定、安全的服务,提升运维效率。最终介绍了集成开发共担模型,旨在通过最佳实践和平台工具,保障业务的稳定与安全,推动行业创新与发展。
|
2月前
|
XML API 开发工具
如何接入电竞体育直播API或者SDK
接入电竞体育直播API或SDK的步骤包括:1. 选择合适的API/SDK提供商,如ESL、Riot Games、Twitch等;2. 注册并获取API密钥;3. 阅读官方文档,了解接口调用和数据处理;4. 实现实时更新,确保数据同步;5. 测试与优化,确保功能稳定;6. 遵守使用规范。通过这些步骤,可成功集成电竞直播功能。
|
3月前
|
安全 API 开发者
微信开发者工具里面没有企业微信模式
企业微信与普通微信在应用场景和开发体系上存在本质区别,主要体现在身份认证、功能丰富性和开放能力等方面。企业微信开发需使用特定的API和工具,本文介绍了企业微信开发的基本步骤、特点及开发进度安排,帮助开发者更好地理解和应用企业微信的开发环境。
|
4月前
|
存储 自然语言处理 API
HarmonyOS SDK使用:熟悉HarmonyOS提供的开发工具和API
【10月更文挑战第21天】随着智能设备的普及,操作系统的重要性日益凸显。华为推出的HarmonyOS凭借其跨平台、分布式特性受到广泛关注。本文将从开发工具、API使用、SDK更新维护及社区支持等方面,探讨HarmonyOS SDK的使用,旨在帮助开发者高效利用这一强大平台,开启鸿蒙应用开发之旅。
208 5
|
4月前
|
编译器 API 定位技术
API和SDK的区别
API(应用程序编程接口)和SDK(软件开发工具包)的主要区别在于范围、内容、抽象程度及使用方式。API定义了软件组件间的交互规则,范围较窄,更抽象;而SDK提供了一整套开发工具,包括API、编译器、调试器等,范围广泛,具体且实用,有助于提高开发效率。
|
4月前
|
编译器 API 定位技术
API和SDK的区别
API 和 SDK 的区别在于:API 是一组定义了软件组件之间交互规范的接口,用于实现不同软件组件之间的通信;而 SDK 是一个全面的工具集合,包含 API、编译器、调试器、文档等,用于特定平台的应用程序开发。SDK 范围更广,内容更丰富,更具体和具象化,适合复杂的开发需求;API 则更加抽象,侧重于功能的定义和调用方式。
|
6月前
|
JSON Java API
【Azure API 管理】通过Java APIM SDK创建一个新的API,如何为Reqeust的Representation设置一个内容示例(Sample)?
【Azure API 管理】通过Java APIM SDK创建一个新的API,如何为Reqeust的Representation设置一个内容示例(Sample)?
|
6月前
|
Web App开发 缓存 小程序
【Azure API 管理】从微信小程序访问APIM出现200空响应的问题中发现CORS的属性[terminate-unmatched-request]功能
【Azure API 管理】从微信小程序访问APIM出现200空响应的问题中发现CORS的属性[terminate-unmatched-request]功能
|
6月前
|
API 开发工具 图形学
PicoVR Unity SDK⭐️五、常用API接口函数一览
PicoVR Unity SDK⭐️五、常用API接口函数一览
|
6月前
|
缓存 JavaScript 前端开发
微信 JS-SDK Demo “分享信息设置” API 及数字签名生成方法(NodeJS版本)
微信 JS-SDK Demo “分享信息设置” API 及数字签名生成方法(NodeJS版本)更新时间(2020-10-29)

热门文章

最新文章