我曾尝试以机器人用户的身份使用chat.postmessage方法发送消息,并将用户id放在通道的位置。我想从slack team user中的特定用户id中发送任何用户。
发布于 2017-07-31 05:43:33
如果你有Slack机器人,你必须使用Slack API中的Incoming Webhooks。您只需发送带有JSON数据的web请求,例如:
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();
https://stackoverflow.com/questions/45404309
复制相似问题