aris
1
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] = “[email protected]”
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]”] = “[email protected]”
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” => “[email protected]”,
“login”
=> “passwd”}})
has no luck either.
but with
req.set_form_data({“login[account]” => “[email protected]”,
“login[passwd]” => “whatever”})
doing the job.
Any ideas?
Thanks
–
Silence is golden.
twitter: @areverie
wikipedia: AleiPhoenix
blog: weblog.areverie.org
wiki: wiki.areverie.org
On Dec 16, 2012, at 6:53 AM, “AleiPhoenix (A.K.A Areverie)”
[email protected] wrote:
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]”] = “[email protected]”
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” => “[email protected]”, “login” =>
“passwd”}})
has no luck either.
This is how the web browser sends the parameters.
but with
req.set_form_data({“login[account]” => “[email protected]”, “login[passwd]” =>
“whatever”})
doing the job.
Any ideas?
Use this last one.
Got it, thanks.
On Mon, Dec 17, 2012 at 6:20 AM, Eric H. [email protected]
wrote:
req[“login[passwd]”] = “whatever”
req.set_form_data({“login” => {“account” => “[email protected]”,
doing the job.
Any ideas?
Use this last one.
–
Silence is golden.
twitter: @areverie
wikipedia: AleiPhoenix
blog: weblog.areverie.org
wiki: wiki.areverie.org