Hi,
I'm currently working on a script doing login function with a website.
The login action requires a hash-like parameters as
login[account] = "foobar@example.com"
login[passwd] = "whatever"
setting params in net/http like
require "net/http"
require "net/https"
https = Net::HTTP.new("passport.115.com", 443)
https.use_ssl = true
req = Net::HTTP::Post.new("/?ac=login")
req["login[account]"] = "foobar@example.com"
req["login[passwd]"] = "whatever"
res = https.request(req)
p res.to_hash
won't work, looks like the params weren't passed properly.
and with
req.set_form_data({"login" => {"account" => "foobar@example.com", "login"
=> "passwd"}})
has no luck either.
but with
req.set_form_data({"login[account]" => "foobar@example.com",
"login[passwd]" => "whatever"})
doing the job.
Any ideas?
Thanks
···
--
Silence is golden.
twitter: @areverie
wikipedia: AleiPhoenix
blog: weblog.areverie.org
wiki: wiki.areverie.org
I'm currently working on a script doing login function with a website.
The login action requires a hash-like parameters as
login[account] = "foobar@example.com"
login[passwd] = "whatever"
setting params in net/http like
require "net/http"
require "net/https"
https = Net::HTTP.new("passport.115.com", 443)
https.use_ssl = true
req = Net::HTTP::Post.new("/?ac=login")
Net::HTTPRequest# sets request headers, not form data.
req["login[account]"] = "foobar@example.com"
req["login[passwd]"] = "whatever"
res = https.request(req)
p res.to_hash
won't work, looks like the params weren't passed properly.
and with
This is not how the web browser is set up to send the parameters.
req.set_form_data({"login" => {"account" => "foobar@example.com", "login" => "passwd"}})
has no luck either.
This is how the web browser sends the parameters.
but with
req.set_form_data({"login[account]" => "foobar@example.com", "login[passwd]" => "whatever"})
doing the job.
Any ideas?
Use this last one.
···
On Dec 16, 2012, at 6:53 AM, "AleiPhoenix (A.K.A Areverie)" <aleiphoenix@gmail.com> wrote: