Forum: Ruby Net::HTTP and submitting forms

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
73606b1d1042de19056f3d59492b652f?d=identicon&s=25 Charlie Bowman (beachguy82)
on 2006-02-24 00:13
I have a little snippet of code I wrote but it doesn't go to the correct
page.  The script pulls the data off of index.php but not
index.php?pid=fact&person=chuck.  What am I doing wrong?

require 'net/http'
res = Net::HTTP.post_form(URI.parse('http://www.4q.cc/index.php'),
                                  {'pid'=>'fact', 'person'=>'chuck'})
puts res.body



charlie bowman
recentrambles.com
Cd2382441bbe2ec68e3bf36aea0ca2ea?d=identicon&s=25 Adam Keys (Guest)
on 2006-02-24 18:33
(Received via mailing list)
On Feb 23, 2006, at 5:13 PM, charlie bowman wrote:
> I have a little snippet of code I wrote but it doesn't go to the
> correct
> page.  The script pulls the data off of index.php but not
> index.php?pid=fact&person=chuck.  What am I doing wrong?
>
> require 'net/http'
> res = Net::HTTP.post_form(URI.parse('http://www.4q.cc/index.php'),
>                                   {'pid'=>'fact', 'person'=>'chuck'})
> puts res.body

#post_form will put the parameters you pass in the request body.  If
your PHP script doesn't care about GET or POST, you could make the
request like any other GET, appending ?pid=fact&person=chuck to your
URL.
89d967359903c639d31e4cad4569f537?d=identicon&s=25 Charlie Bowman (Guest)
on 2006-02-24 20:50
(Received via mailing list)
Thank you.  The following worked fine.

res =
Net::HTTP.get(URI.parse('http://www.4q.cc/index.php?pid=fact&person=chuck'))
puts res
This topic is locked and can not be replied to.