50,530
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
//应用ID 账号 部门 标签 消息类型 内容
Send_msg("5","SL00007","","1","text","嘎嘎");
}
public static int Send_msg(String agentid,String touser,String toparty,String totag,String msgtype,String content){
int errCode=0;
//拼接请求地址
String requestUrl=WXURLUtil.SEND_MSG_URL.replace("ACCESS_TOKEN", GetAccessToken.getAccessToken());
//需要提交的数据
String postJson = "{\"agentid\":\"%s\",\"touser\":\"%s\",\"toparty\":\"[1, %s]\",\"totag\":\"%s\",\"msgtype\":\"text\",\"%s\":{\"content\":\"%s\"},\"safe\":\"0\"}";
String outputStr=String.format(postJson,agentid,touser,toparty,totag,msgtype, content);
System.out.println(outputStr);
//创建成员
JSONObject jsonObject=CommonUtil.httpsRequest(requestUrl, "POST", outputStr);
if(null!=jsonObject){
System.out.println(jsonObject.toString()+"=====");
// int errcode = jsonObject.getInt("errcode");
// errCode=jsonObject.getInt("errcode");
}
return errCode;
}
// 发送消息
public static String SEND_MSG_URL = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN";