How do make it post instead of get?

This script will GET the page i request when i call it from dos-prompt
like this “ruby nukeuser.rb 1”


require ‘uri’
require ‘net/https’

user_id = ARGV[0].strip
url = “https:///services_captiveportal_users.php?act=del&id=” + user_id

url1 = URI.parse(url)

http = Net::HTTP.new(url1.host, url1.port)
http.use_ssl = true

Do not warn us about certificate - blithely accept whatever

certificate we receive!
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

req = Net::HTTP::Get.new(url1.path)
req.basic_auth ‘username’, ‘password’

res = http.start do |h|
h.request(req)
end

print res.body


But i really need to POST… and cant figure out how to make it do that
:-/
Can someone please help - i am loosing my hair fast at the moment!

Change

req = Net::HTTP::Get.new(url1.path)

to

req = Net::HTTP::Post.new(url1.path)

?

On Wed, Jul 9, 2008 at 2:33 PM, Flemming Munk jensen <
[email protected]> wrote:

Can someone please help - i am loosing my hair fast at the moment!

Posted via http://www.ruby-forum.com/.


Paul S.
DCI Level 2 Judge, Bath FNM Organiser

Upcoming events in Bath - nomadicfun.co.uk
July 12th Eventide Prerelease (Standard)

[email protected]

Paul S. wrote:

Change

req = Net::HTTP::Get.new(url1.path)

to

req = Net::HTTP::Post.new(url1.path)

?

Well… that run’s without any errors too, but i dont get the result i
would like.

I think i will explain a little more about what i am trying to do :wink:

I have a webpage on a m0n0wall (see http://m0n0.ch/wall/) where you can
do some user management. On this page is a link that is marked up like
this:



Now what i want ruby to do is call the page
services_captiveportal_users.php with the action “act=del” and the
apropriate “id=?”, so i can delete users this way.

What happens so far, is i get the page with a list of all users
currently registered, wich is ok, but the user id i request to be
deleted is not deleted??

Is it maybe because of the "onclick=“return…blah” in the href??
I have the feeling i am missing some basic law of nature here, and in
the process of embarassing myself bigtime…

Thanks in advantage

BR
Flemming

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