2017-07-30 45 views
-1

我曾尝试通过chat.postmessage方法以闲置方式发送消息作为僵尸用户,并将用户标识置于通道位置。我想从松散团队用户的特定用户ID发送任何用户。如何从特定用户向特定用户发送消息,并在网点中存在松动

+0

您的问题描述非常宽泛。请包括您尝试过的部分代码以及您可能收到的任何错误消息。这将帮助你获得答案。另请查看[如何提问](https://stackoverflow.com/help/how-to-ask)。 –

回答

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(); 
相关问题