我曾尝试使用chat.postmessage方法将消息作为僵尸用户发送,并将用户ID放在频道的位置。我想在slack team用户中发送来自特定用户ID的任何用户。
答案 0 :(得分:0)
如果您有Slack bot,则必须使用Slack API中的Incoming Webhooks。您只需使用JSON数据发送网络请求,例如:
string exampleJson = " { \"text\": \"This is a line of text.\nAnd this is another one.\" }";
var http = (HttpWebRequest)WebRequest.Create(new Uri("YOUR-SLACK-WEBHOOK-URL"));
http.ContentType = "application/json";
http.Method = "POST";
Byte[] bytes = new ASCIIEncoding().GetBytes(exampleJson);
Stream newStream = http.GetRequestStream();
newStream.Write(bytes, 0, bytes.Length);
newStream.Close();
new StreamReader(http.GetResponse().GetResponseStream()).ReadToEnd();