为什么我无法通过聊天 postMessage api 向用户发送消息?
Why I am unable to send message to the user via chat postMessage api?
我们有与 Slack API 集成的应用程序,并通过 https://api.slack.com/methods/chat.postMessage Slack API 发送消息。最近这个 API 开始无法向用户发送消息并显示错误消息:method_deprecated
。我找不到它在上个月被弃用和停止工作的原因。
为了发送消息,我们使用以下内容:
String userId = slackFacade.getUserId(recipientEmail);
String channelId = slackFacade.getDirectChannelId(userId);
slackFacade.postMessage(
Message.builder()
.channel(channelId)
.text(message)
.mrkdwn(true)
.attachment(attachment)
.build());
slackFacade 实现的样子:
public String getUserId(String email) throws SlackCommunicationException {
return logErrors(slackClient.getUserByEmail(email)).getUser().getId(); //users.lookupByEmail
}
public String getDirectChannelId(String userId) throws SlackCommunicationException {
return logErrors(slackClient.imOpen(userId)).getChannel().getId();
}
我找到了根本原因。实际上 chat.postMessage 没有问题,但它是与 imOpen API 相关的更改的一部分:
https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api
我们有与 Slack API 集成的应用程序,并通过 https://api.slack.com/methods/chat.postMessage Slack API 发送消息。最近这个 API 开始无法向用户发送消息并显示错误消息:method_deprecated
。我找不到它在上个月被弃用和停止工作的原因。
为了发送消息,我们使用以下内容:
String userId = slackFacade.getUserId(recipientEmail);
String channelId = slackFacade.getDirectChannelId(userId);
slackFacade.postMessage(
Message.builder()
.channel(channelId)
.text(message)
.mrkdwn(true)
.attachment(attachment)
.build());
slackFacade 实现的样子:
public String getUserId(String email) throws SlackCommunicationException {
return logErrors(slackClient.getUserByEmail(email)).getUser().getId(); //users.lookupByEmail
}
public String getDirectChannelId(String userId) throws SlackCommunicationException {
return logErrors(slackClient.imOpen(userId)).getChannel().getId();
}
我找到了根本原因。实际上 chat.postMessage 没有问题,但它是与 imOpen API 相关的更改的一部分: https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api