Post to a remote page

Hi all,

I am sorry if this question has already been replied here, but I did not
manage to find an answer.

I am looking for a way to post data to a remote web page. I don’t want
to use hidden fields and a submit button, I would just like some ruby
code that would post parametres to a web page and store the web page
that the remote server sends back.

I am not sure that I have been clear, so, here is an example.

I have a simple page on a php server B that contains the code

print ($_POST[‘var1’]+$_POST[‘var1’]);

And I have my ruby server A, and what I would like to do is post var1
and var2 to server B and store the answer (A+B) that server B gives me

Is it possible to do such a thing?

I hope that someone will be able to help me!

Thank you very much!

You can use Net::HTTP to do an HTTP transfer inside of one of your
scripts, and then save the result. I’ve never done it, but honestly, it
shouldn’t be hard. Check for the API.


Thanks a lot!


Are you bound to POST? You could use a REST-like approach and hit the
remote page with GET requests via net/http and parse the response.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs