【发布时间】:2016-10-27 18:03:06
【问题描述】:
我正在研究用于教授 Ruby 中的 API 使用的 Slack API。 Slack API 是否需要将所有参数作为查询字符串的一部分,还是也可以采用 post-Params。
这样的消息有效:
def self.sendmsg(channel, msg)
url = BASE_URL + "chat.postMessage?" + "token=#{TOKEN}" + "&text=#{msg}&channel=#{channel}"
data = HTTParty.post(url)
end
但事实并非如此:
def self.sendmsg(channel, msg)
url = BASE_URL + "chat.postMessage?" + "token=#{TOKEN}"
data = HTTParty.post(url,
body: {
"text" => "#{msg}",
"channel" => "#{channel}"
}.to_json,
:headers => { 'Content-Type' => 'application/json' } )
end
【问题讨论】: