第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

企業(yè)微信機(jī)器人自動(dòng)消息發(fā)送webhook接入代碼

標(biāo)簽:
Java

主要代码类如下

package com.test.common;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.json.JSONObject;
/*
 * 文件名:com.test.common;.SendRobotMsgUtils.java
 * 简述:TODO
 * 详述: 
 * 新建时间:2022年5月2日 下午12:31:41
 * 修改内容:[新增]
 * 修改时间:2022年5月2日 下午12:31:41
 * 版本:1.0
 * 
 */
public class SendRobotMsgUtils {
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public boolean wechatRobotTxtMsg(String webhookUrl,String msgContent,List<String> mentioned_mobile_list) {
		boolean falg=false;
		//webhook地址 
		String msgtype="text";
        HttpResponse response=null;
        try {
        	if(webhookUrl!=null&&msgContent!=null) {
        	HttpPost httpPost=new HttpPost(webhookUrl);
        	CloseableHttpClient httpclient=HttpClients.createDefault();
        	httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
        	Map<String,Object> param=new HashMap();
        	param.put("msgtype",msgtype);
        	Map<String,Object> param_msg=new HashMap();
        	param_msg.put("content", msgContent);
        	if(mentioned_mobile_list!=null&&mentioned_mobile_list.size()>0) {
        		param_msg.put("mentioned_mobile_list", mentioned_mobile_list);
        	}
        	//封装消息体
        	param.put(msgtype, param_msg);
        	String txtmsg=JSONObject.valueToString(param);
        	System.out.println("*************执行前txtmsg:"+txtmsg);
        	StringEntity entity = new StringEntity(txtmsg, "utf-8");
        	httpPost.setEntity(entity);
        	System.out.println("*************执行前:"+httpPost.toString());
			response=httpclient.execute(httpPost);
			if(response!=null&&response.getStatusLine()!=null&&response.getStatusLine().getStatusCode()==200) {
				String responseStr=response.getEntity().toString();
				falg=true;
				System.out.println("*************执行结果:"+responseStr);
			}
			}else {
				System.out.println("*************输入参数为空********************************");
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return falg;
	}
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public boolean wechatRobotMarkdownMsg(String webhookUrl,String msgContent,List<String> mentioned_mobile_list) {
		boolean falg=false;
		//webhook地址 
		String msgtype="markdown";
        HttpResponse response=null;
        try {
        	if(webhookUrl!=null&&msgContent!=null) {
        	HttpPost httpPost=new HttpPost(webhookUrl);
        	CloseableHttpClient httpclient=HttpClients.createDefault();
        	httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
        	Map<String,Object> param=new HashMap();
        	param.put("msgtype",msgtype);
        	Map<String,Object> param_msg=new HashMap();
        	param_msg.put("content", msgContent);
        	if(mentioned_mobile_list!=null) {
        		param_msg.put("mentioned_mobile_list", mentioned_mobile_list);
        	}
        	//封装消息体
        	param.put(msgtype, param_msg);
        	String txtmsg=JSONObject.valueToString(param);
        	System.out.println("*************执行前txtmsg:"+txtmsg);
        	StringEntity entity = new StringEntity(txtmsg, "utf-8");
        	httpPost.setEntity(entity);
        	System.out.println("*************执行前:"+httpPost.toString());
			response=httpclient.execute(httpPost);
			if(response!=null&&response.getStatusLine()!=null&&response.getStatusLine().getStatusCode()==200) {
				String responseStr=response.getEntity().toString();
				falg=true;
				System.out.println("*************执行结果:"+responseStr);
			}
			}else {
				System.out.println("*************输入参数为空********************************");
			}
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return falg;
	}
	public static void main(String[] args) {
		SendRobotMsgUtils srmu=new SendRobotMsgUtils();
		SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:SSS");
		String nowstr=sdf.format(new Date());
		String webhookUrl="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=c17661d0c2e6";
		String msgContent="监控机器人-普通文本消息\n消息时间:"+nowstr+";\n交易日期+支付渠道+渠道笔数+当日总笔数\n"
				+ "你们所有人可以关闭此群消息!!!";
		List<String> mlist=new ArrayList<String>();
        mlist.add("@all");
        mlist.add("18688888888");
//		srmu.wechatRobotTxtMsg(webhookUrl,msgContent,mlist);
        String msgmkContent=
        		"<h2>监控名称</h2>\r\n" + 
        		"				<tr style=\"border: 3px ;border-color: black;\">\r\n" + 
        		"					<th width=\"25%\">编号</th>\r\n" + 
        		"					<th width=\"25%\">用户名</th>\r\n" + 
        		"					<th width=\"25%\">姓名</th>\r\n" + 
        		"					<th width=\"25%\">联系电话</th>\r\n" + 
        		"				</tr>\r\n" + 
        		"				\r\n" + 
        		"				<tr>\r\n" + 
        		"					<td style=\"border: 3px ;border-color: black;\">01</td>\r\n" + 
        		"					<td >张三</td>\r\n" + 
        		"					<td >姓名</td>\r\n" + 
        		"					<td >18688888888</td>\r\n" + 
        		"				</tr>\r\n" + 
        		"\r\n";
        srmu.wechatRobotMarkdownMsg(webhookUrl, msgmkContent, mlist);

	}

}

实际开发完成的功能效果可以访问:https://www.onekbit.com/wechatrobotinfo/selectlist.do 体验使用。

file

使用微信机器人定时群发消息:

file

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消