I need to hit an https link and pass a username and password in order to
pull down some records in xml format. I was thinking that the easiest
way to do this is to shell out to curl and then parse my xml provided
that I could pass the username/password in the url.
Can anyone recommend an easy way to accomplish this?
On Fri, Nov 12, 2010 at 2:12 AM, jackster the jackle [email protected] wrote:
I need to hit an https link and pass a username and password in order to
pull down some records in xml format. I was thinking that the easiest
way to do this is to shell out to curl and then parse my xml provided
that I could pass the username/password in the url.
Can anyone recommend an easy way to accomplish this?
The ruby way of doing this would be to use the Net::HTTP from the
standard library. It does https too. The docs are at:
As for parsing XML, there are a few options, but Nokogiri is probably
the easiest to learn and deal with. Easily googlable, and there are a
few blog posts with samples.
thanks alot for the advise. I have used Net::HTTP alot in the past but
could never get it working with HTTPS but I’ll read the docs again and
have at it…
On Fri, Nov 12, 2010 at 3:49 AM, jackster the jackle [email protected] wrote:
thanks alot for the advise. I have used Net::HTTP alot in the past but
could never get it working with HTTPS but I’ll read the docs again and
have at it…
The difference between http and https with Net:HTTP can be summed by:
require ‘net/https’ # extra require
http = Net::HTTP.new(‘server.net’, 443) # note the port
http.use_ssl = true # turn it on
On Fri, Nov 12, 2010 at 2:06 PM, jackster the jackle [email protected] wrote:
stand people like you who think they are smarter than everyone else and
pretend to help by giving stupid little hints…
In an earlier post you wrote: “I have used Net::HTTP alot in the
past”. Your last question clearly indicates that you are not telling
the truth. And it shows that you didn’t even try to read the docs. I
was willing to help, but I’m not willing to do the work for you.
There is this really cool tool that all us programmers know about but
we never tell the noobs. But as you asked so nice I will tell you. Its
called google
Try this query “read an https url in ruby”, look at the first result.
Looks interesting?
As you have displayed no ability to solve your own problems and an
inflated sense of your own importance I think that you will probably
go nowhere. Ammar has done his best to help you, you however have
expected everything to be given to you on a plate. Behave like a child
and you will be treated like a child.
Please read the documentation to find out how to use the instance you
created.
Good luck,
Ammar
What, have you suddenly decided to play the “school master”? I can’t
stand people like you who think they are smarter than everyone else and
pretend to help by giving stupid little hints…get lost Ammar
On Friday, November 12, 2010, jackster the jackle [email protected]
wrote:
What, have you suddenly decided to play the “school master”? I can’t
stand people like you who think they are smarter than everyone else and
pretend to help by giving stupid little hints…get lost Ammar
Aggression won’t get you anywhere. So, go read the documentation, and
if you have specific questions, we are happy to help. But read the
docs first. That’s what it’s there for.
–
Phillip G.
Though the folk I have met,
(Ah, how soon!) they forget
When I’ve moved on to some other place,
There may be one or two,
When I’ve played and passed through,
Who’ll remember my song or my face.
I’m not a developer…I’m a network engineer and have been for 15
years…I have also been a member of this forum (off and on) for the
last 5 years or so.
Believe me, I google everything and try and figure it out before I post
on the forum…I’m sorry, I don’t understand everything I read in the
docs like you guys do…much of it is a foreign language to me.
I have been able to get some things working over the years by trial and
error and by modifying and expanding some base snippets of code…much
of the help I received on this forum by people who were willing to help
even dummies like me.
If someone I didn’t know asked me networking questions I wouldn’t tell
them to RTFM…that is what know it alls do.
I appreciate any and all help from Ammar and I’m sorry I got upset but I
can’t deal with people that deliberately hold back info to try and teach
people some kind of lesson.
That is a good way of doing it, a step at a time through irb…I don’t
usually do it that way but it seems to be a good way to isolate the
failure if any.
When I get down to the line “http.use_ssl = true”, it fails with this
error message:
irb(main):004:0> http.use_ssl = true
NoMethodError: undefined method `use_ssl=’ for #<Net::HTTP myurl.com:443
open=false>
from (irb):4
irb(main):005:0>
On 11/12/2010 03:23 PM, jackster the jackle wrote:
need requires a one time username and password which I am having trouble
Am I proceeding down the right path with the authentication?
Both approaches above should be equivalent. Question is which
authentication method the website uses. It may as well be form fields
(sent via POST for example) or even via a certificate.
That is a good way of doing it, a step at a time through irb…I don’t
usually do it that way but it seems to be a good way to isolate the
failure if any.
When I get down to the line “http.use_ssl = true”, it fails with this
error message:
irb(main):004:0> http.use_ssl = true
NoMethodError: undefined method `use_ssl=’ for #<Net::HTTP myurl.com:443
open=false>
from (irb):4
irb(main):005:0>
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.