com.tmsps.ne4weixin.api.CustomAPI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ne4weixin Show documentation
Show all versions of ne4weixin Show documentation
Ne4WeiXin For Spring is good :)
package com.tmsps.ne4weixin.api;
import com.alibaba.fastjson.JSONObject;
import com.tmsps.ne4weixin.bean.message.custom.BaseMessage;
import com.tmsps.ne4weixin.config.WxConfig;
import com.tmsps.ne4weixin.config.constant.CUSTOM;
import com.tmsps.ne4weixin.utils.WXHttpUtil;
import lombok.extern.slf4j.Slf4j;
/**
* @Title: CustomAPI.java
* @Package: com.tmsps.ne4weixin.api
* @Description: 客服消息管理API
* @author: hanjiefei
* @date: 2019-10-22
* @version V1.0
* @Copyright: 2019
*/
@Slf4j
public class CustomAPI extends BaseAPI {
public CustomAPI(WxConfig config) {
super(config);
}
/**
* 发送客服消息
* @param message
* @return
*/
public String sendMessage(BaseMessage message) {
String url = String.format(CUSTOM.SEND_MSG, wxConfig.getAccessToken());
log.debug(JSONObject.toJSONString(message));
return WXHttpUtil.postJson(url, JSONObject.toJSONString(message));
}
/**
* 发送客服消息
* @param json
* @return
*/
public String sendMessage(String json) {
String url = String.format(CUSTOM.SEND_MSG, wxConfig.getAccessToken());
return WXHttpUtil.postJson(url, json);
}
}