Java调用钉钉接口实现机器人群消息推送

Java调用钉钉接口实现机器人群消息推送_第1张图片
Java调用钉钉接口实现机器人群消息推送_第2张图片
Java调用钉钉接口实现机器人群消息推送_第3张图片

实现类接口:
public String tuiShong() {
try{

        DingTalkClient client =new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=b6a92a5f659e753da181fdeab630cf9ec6e3e7e8817dbb4bfd389d3f4425c0cb");

        OapiRobotSendRequest request=new OapiRobotSendRequest();

        request.setMsgtype("test");

        OapiRobotSendRequest.Text test =new OapiRobotSendRequest.Text();

        test .setContent("试试测试文本消息java发送");

        request.setText(test);

        OapiRobotSendRequest.At at=new OapiRobotSendRequest.At();

        at.setAtMobiles(Arrays.asList("18661578641"));

        request.setAt(at);

        request.setMsgtype("link");

        OapiRobotSendRequest.Link link=new OapiRobotSendRequest.Link();

        link.setMessageUrl("https://www.dingtalk.com");

        link.setPicUrl("");

        link.setTitle("试试这个是新版本");

        request.setLink(link);

        request.setMsgtype("markdown");

        OapiRobotSendRequest.Markdown markdown=new OapiRobotSendRequest.Markdown();

        markdown.setTitle("北京天气");

        markdown.setText("请填写日报。。。");

        request.setMarkdown(markdown);

        OapiRobotSendResponse response=client.execute(request);

        System.out.println(response.getErrmsg());
        //错误信息
    } catch (Exception e){
        return e.toString();
    }
    return "发送成功!";
}

你可能感兴趣的:(java,钉钉,servlet)