Class WeChatWorkRobotClient

java.lang.Object
com.bytedesk.wechat.work.WeChatWorkRobotClient

@Component public class WeChatWorkRobotClient extends Object
企业微信群机器人客户端 文档: https://developer.work.weixin.qq.com/document/path/91770
  • Field Details

    • restTemplate

      private final org.springframework.web.client.RestTemplate restTemplate
    • objectMapper

      private final com.fasterxml.jackson.databind.ObjectMapper objectMapper
    • BASE_URL

      private static final String BASE_URL
      See Also:
  • Constructor Details

    • WeChatWorkRobotClient

      public WeChatWorkRobotClient()
  • Method Details

    • sendText

      public Map<String,Object> sendText(String key, String content, List<String> mentionedList, List<String> mentionedMobileList)
      发送文本消息
      Parameters:
      key - webhook的key
      content - 文本内容
      mentionedList - 要@的用户ID列表
      mentionedMobileList - 要@的手机号列表
      Returns:
      发送结果
    • sendMarkdown

      public Map<String,Object> sendMarkdown(String key, String content)
      发送Markdown消息
      Parameters:
      key - webhook的key
      content - Markdown内容
      Returns:
      发送结果
    • sendImage

      public Map<String,Object> sendImage(String key, String base64, String md5)
      发送图片消息
      Parameters:
      key - webhook的key
      base64 - 图片的base64编码
      md5 - 图片的md5值
      Returns:
      发送结果
    • sendNews

      public Map<String,Object> sendNews(String key, List<Map<String,String>> articles)
      发送图文消息
      Parameters:
      key - webhook的key
      articles - 图文消息列表
      Returns:
      发送结果
    • sendFile

      public Map<String,Object> sendFile(String key, String mediaId)
      发送文件消息
      Parameters:
      key - webhook的key
      mediaId - 文件ID
      Returns:
      发送结果
    • sendMessage

      private Map<String,Object> sendMessage(String key, Map<String,Object> message)
      通用消息发送方法
      Parameters:
      key - webhook的key
      message - 消息内容
      Returns:
      发送结果