【发布时间】:2016-03-10 10:16:34
【问题描述】:
我有两个从 NodeJS 文件到 slack 的 API 调用,通过 api 发布消息效果很好,但尝试获取频道历史记录返回 JSON { error: "channel_not_found", ok: false }。
令牌是硬编码的。
chat.js
Chat.sendMessage = function (text, callback) {
slack.api('chat.postMessage', {
text:text,
as_user:true,
channel:'#webhooksapi'
}, function(err, response){
callback(null,response);
});
}
//Getting error on this function
Chat.getMessage = function (channel, callback){
slack.api('channels.history', {
token:apiToken,
channel:'#webhooksapi'
}, function(err, response){
callback(null, response);
});
}
【问题讨论】:
-
请附上channel list
-
根据 api 手册“为通道传递的值无效。” api.slack.com/methods/channels.history
-
做了频道列表命令,看到频道有一个ID,想尝试一下,它成功了
-
正确@Jimmie 尚不清楚:即使在测试选项卡中,我们也有“#general”作为提示,但如果您插入“#general”,我们会看到“找不到频道”。该参数应为频道 ID
标签: javascript node.js slack-api