2017-07-30 33 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(); 
相關問題