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
가장 깨끗한 대답은 다음과 같습니다.
url = 'https://someslackwebhookurl/adfdsf/sdfsfsd'
msg = 'We are fumanchu'
HTTParty.post(url, body: {"text":"#{msg}"}.to_json)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다