Ruby on Rails如何通过Slack Incoming Webhook API实现长尾词消息推送?

2026-04-10 07:071阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计272个文字,预计阅读时间需要2分钟。

Ruby on Rails如何通过Slack Incoming Webhook API实现长尾词消息推送?

我可以通过CURL POST到Slack的API端点传入内容,但实际使用中它不能正常工作。如果关闭,我假设格式化。我该如何解决这个问题?

parms={ text: text_for_slack, channel: channel }

我可以通过CURL POST到Slack传入的API端点,但是当尝试使用下面的它不能正常工作时.如果关闭,我假设格式化.我怎样才能解决这个问题?

parms = {text: text_for_slack, channel: "#customer_sessions", username: "SessionBot", icon_emoji: ":raised_hands:"} x = Net::HTTP.post_form(URI.parse(ENV['SessionSlackURL'].to_s), parms.to_s) 您可以使用两种方法发布(来自传入webhook的松弛配置文本):

You have two options for sending data to the Webhook URL above:
Send a JSON string as the payload parameter in a POST request
Send a JSON string as the body of a POST request

json在体内.

Ruby on Rails如何通过Slack Incoming Webhook API实现长尾词消息推送?

require "net/http" require "uri" require "json" parms = { text: text_for_slack, channel: "#customer_sessions", username: "SessionBot", icon_emoji: ":raised_hands:" } uri = URI.parse(ENV['SessionSlackURL']) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request.body = parms.to_json response = http.request(request)

json作为参数

parms_form = { "payload" => { text: text_for_slack, channel: "#customer_sessions", username: "SessionBot", icon_emoji:":raised_hands:" }.to_json } request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(parms_form)

本文共计272个文字,预计阅读时间需要2分钟。

Ruby on Rails如何通过Slack Incoming Webhook API实现长尾词消息推送?

我可以通过CURL POST到Slack的API端点传入内容,但实际使用中它不能正常工作。如果关闭,我假设格式化。我该如何解决这个问题?

parms={ text: text_for_slack, channel: channel }

我可以通过CURL POST到Slack传入的API端点,但是当尝试使用下面的它不能正常工作时.如果关闭,我假设格式化.我怎样才能解决这个问题?

parms = {text: text_for_slack, channel: "#customer_sessions", username: "SessionBot", icon_emoji: ":raised_hands:"} x = Net::HTTP.post_form(URI.parse(ENV['SessionSlackURL'].to_s), parms.to_s) 您可以使用两种方法发布(来自传入webhook的松弛配置文本):

You have two options for sending data to the Webhook URL above:
Send a JSON string as the payload parameter in a POST request
Send a JSON string as the body of a POST request

json在体内.

Ruby on Rails如何通过Slack Incoming Webhook API实现长尾词消息推送?

require "net/http" require "uri" require "json" parms = { text: text_for_slack, channel: "#customer_sessions", username: "SessionBot", icon_emoji: ":raised_hands:" } uri = URI.parse(ENV['SessionSlackURL']) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request.body = parms.to_json response = http.request(request)

json作为参数

parms_form = { "payload" => { text: text_for_slack, channel: "#customer_sessions", username: "SessionBot", icon_emoji:":raised_hands:" }.to_json } request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(parms_form)