|
@@ -1,13 +1,18 @@
|
|
package org.fouram.core.plugin.weixin.cp.util;
|
|
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.plugin.weixin.cp.core.WXCpMessage;
|
|
import org.fouram.core.util.ConfConfig;
|
|
import org.fouram.core.util.ConfConfig;
|
|
import org.fouram.core.util.LoggerUtil;
|
|
import org.fouram.core.util.LoggerUtil;
|
|
|
|
|
|
-import me.chanjar.weixin.common.api.WxConsts.XmlMsgType;
|
|
|
|
|
|
+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.common.error.WxErrorException;
|
|
import me.chanjar.weixin.cp.bean.WxCpMessage;
|
|
import me.chanjar.weixin.cp.bean.WxCpMessage;
|
|
import me.chanjar.weixin.cp.bean.WxCpMessageSendResult;
|
|
import me.chanjar.weixin.cp.bean.WxCpMessageSendResult;
|
|
|
|
+import me.chanjar.weixin.cp.bean.article.NewArticle;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 企业微信用户工具类
|
|
* 企业微信用户工具类
|
|
@@ -16,12 +21,15 @@ import me.chanjar.weixin.cp.bean.WxCpMessageSendResult;
|
|
*/
|
|
*/
|
|
public class WXCpMessageUtil {
|
|
public class WXCpMessageUtil {
|
|
|
|
|
|
- public static void sendQuitUserMsg(String content) throws WxErrorException {
|
|
|
|
|
|
+ public static void sendQuitUserMsg(String title) throws WxErrorException {
|
|
try {
|
|
try {
|
|
WxCpMessage message = new WxCpMessage();
|
|
WxCpMessage message = new WxCpMessage();
|
|
message.setToUser(ConfConfig.getConfigString("wxCp.massage.toUser"));
|
|
message.setToUser(ConfConfig.getConfigString("wxCp.massage.toUser"));
|
|
- message.setMsgType(XmlMsgType.TEXT);
|
|
|
|
- message.setContent(content);
|
|
|
|
|
|
+ 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);
|
|
WxCpMessageSendResult sendResult = WXCpMessage.service.messageSend(message);
|
|
WxCpMessageSendResult sendResult = WXCpMessage.service.messageSend(message);
|
|
LoggerUtil.info(sendResult.toString());
|
|
LoggerUtil.info(sendResult.toString());
|
|
} catch (WxErrorException e) {
|
|
} catch (WxErrorException e) {
|
|
@@ -30,6 +38,6 @@ public class WXCpMessageUtil {
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws WxErrorException {
|
|
public static void main(String[] args) throws WxErrorException {
|
|
- sendQuitUserMsg("1111111111222");
|
|
|
|
|
|
+ sendQuitUserMsg("test");
|
|
}
|
|
}
|
|
}
|
|
}
|