Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException
@Override
public WxCpMessageSendResult messageSend(WxCpMessage message) throws WxErrorException {
String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send";
Integer agentId = message.getAgentId();
if(null == agentId){
message.setAgentId(this.getWxCpConfigStorage().getAgentId());
}
return WxCpMessageSendResult.fromJson(this.post(url, message.toJson()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
public class WxCpMessageAPITest {

@Inject
protected WxCpServiceImpl wxService;
protected WxCpService wxService;

private ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage;

@BeforeTest
Expand All @@ -30,7 +31,7 @@ public void setup() {

public void testSendMessage() throws WxErrorException {
WxCpMessage message = new WxCpMessage();
message.setAgentId(configStorage.getAgentId());
// message.setAgentId(configStorage.getAgentId());
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
message.setToUser(configStorage.getUserId());
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
Expand All @@ -43,10 +44,11 @@ public void testSendMessage() throws WxErrorException {
System.out.println(messageSendResult.getInvalidTagList());
}

@Test
public void testSendMessage1() throws WxErrorException {
WxCpMessage message = WxCpMessage
.TEXT()
.agentId(configStorage.getAgentId())
// .agentId(configStorage.getAgentId())
.toUser(configStorage.getUserId())
.content("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>")
.build();
Expand Down