|
@@ -1,18 +1,12 @@
|
|
|
package org.fouram.core.plugin.weixin.cp.util;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
import org.fouram.core.plugin.weixin.cp.core.WXCpMessage;
|
|
|
-import org.fouram.core.util.ConfConfig;
|
|
|
import org.fouram.core.util.LoggerUtil;
|
|
|
|
|
|
-import com.google.common.collect.Lists;
|
|
|
-
|
|
|
import me.chanjar.weixin.common.api.WxConsts.KefuMsgType;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import me.chanjar.weixin.cp.bean.WxCpMessage;
|
|
|
import me.chanjar.weixin.cp.bean.WxCpMessageSendResult;
|
|
|
-import me.chanjar.weixin.cp.bean.article.NewArticle;
|
|
|
|
|
|
/**
|
|
|
* 企业微信用户工具类
|
|
@@ -21,15 +15,12 @@ import me.chanjar.weixin.cp.bean.article.NewArticle;
|
|
|
*/
|
|
|
public class WXCpMessageUtil {
|
|
|
|
|
|
- public static void sendQuitUserMsg(String title) throws WxErrorException {
|
|
|
+ public static void send(String content, String toUser) throws WxErrorException {
|
|
|
try {
|
|
|
WxCpMessage message = new WxCpMessage();
|
|
|
- message.setToUser(ConfConfig.getConfigString("wxCp.massage.toUser"));
|
|
|
- message.setMsgType(KefuMsgType.NEWS);
|
|
|
- NewArticle article = NewArticle.builder().title(title)
|
|
|
- .url(ConfConfig.getConfigString("wxCp.massage.quitUserUrl")).build();
|
|
|
- List<NewArticle> articles = Lists.newArrayList(article);
|
|
|
- message.setArticles(articles);
|
|
|
+ message.setToUser(toUser);
|
|
|
+ message.setMsgType(KefuMsgType.TEXT);
|
|
|
+ message.setContent(content);
|
|
|
WxCpMessageSendResult sendResult = WXCpMessage.service.messageSend(message);
|
|
|
LoggerUtil.info(sendResult.toString());
|
|
|
} catch (WxErrorException e) {
|
|
@@ -38,6 +29,6 @@ public class WXCpMessageUtil {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws WxErrorException {
|
|
|
- sendQuitUserMsg("test");
|
|
|
+ send("test\njjjjjj\n<a href=\"http://www.baidu.com\">百度一下</a>", "1000001");
|
|
|
}
|
|
|
}
|