Net::HTTP and submitting forms

C

charlie bowman

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
 
A

Adam Keys

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.
 
C

Charlie Bowman

--=-5fTXyRCv1KKF/vTw4fyN
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Thank you. The following worked fine.

res =
Net::HTTP.get(URI.parse('http://www.4q.cc/index.php?pid=fact&person=chuck'))
puts res



#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.

--=-5fTXyRCv1KKF/vTw4fyN--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top