gpt4 book ai didi

ruby-on-rails - 将 POST 数据从 Controller 提交到 Rails 中的另一个网站

转载 作者:数据小太阳 更新时间:2023-10-29 06:21:34 26 4
gpt4 key购买 nike

  1. 用户提交包含一些基本数据的表单。

  2. 数据由 Controller 中的操作接收和处理,并添加更多需要保密的信息。

  3. 然后我需要向外部网站发送一个 post 请求,其中包含来自 Controller 的所有组合数据。

执行此操作的最佳方法是什么?

最佳答案

最简单的方法是使用 ruby​​ 核心库:

require "uri"
require "net/http"

params = {'box1' => 'Nothing is less important than which fork you use. Etiquette is the science of living. It embraces everything. It is ethics. It is honor. -Emily Post',
'button1' => 'Submit'
}
x = Net::HTTP.post_form(URI.parse('http://www.interlacken.com/webdbdev/ch05/formpost.asp'), params)
puts x.body

专业提示:执行异步请求,使用像 delayed_job 这样的 gem或 background_rb

关于ruby-on-rails - 将 POST 数据从 Controller 提交到 Rails 中的另一个网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1195962/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com