【发布时间】:2016-02-16 08:49:06
【问题描述】:
我在 .Net Web API 中获取了频道历史记录。 slack 引用 https://api.slack.com/methods/channels.history 它指出我们需要发布请求。
如果有人可以帮助我编写代码,请。
我已经实现的部分代码:
#region create json payload to send to slack
GetLatestMessage payload = new GetLatestMessage()
{
channel = "###",//value.channel_name,
token = "############################"//added the token i have generated
// user_name = value.user_name,
//text = value.text
};
#endregion
string payloadJson = JsonConvert.SerializeObject(payload);
using (WebClient client = new WebClient())
{
NameValueCollection data = new NameValueCollection();
data["payload"] = payloadJson;
var response = client.UploadValues("https://slack.com/api/channels.history", "POST", data);
//The response text is usually "ok"
string responseText = _encoding.GetString(response);
LogFileWriter("response=" + responseText);
return Request.CreateResponse(HttpStatusCode.OK);
}
【问题讨论】:
-
Stackoverflow 不是免费的编码服务,人们可以在其中完成您的工作。表现出一些努力。你试过什么?什么代码不起作用?您在实现代码时遇到了哪些问题?
-
@RononDex 我已经尝试过我的代码。现在添加我的代码。看看你能不能帮忙。
-
好的,现在您的代码的哪一部分不起作用?
-
我得到的响应是: response={"ok":false,"error":"not_authed"} 这意味着'没有提供身份验证令牌。'但是当我直接在 url (slack.com/api/channels.history?token=###&channel=####) 中传递相同的令牌时,我得到了预期结果的正确 json 响应。
-
现在好多了,如果您使用该信息更新您的问题,我相信有人可以帮助您