How to connect to other server (Like cURL in php) in Ruby on


#1

hi Friends,

i am a new programmer in Ruby On Rails, i need a help regarding

connecting to other server as cURL in php in ROR. so i hope got my
query.

that is i need to connect my page to other server to reteive some
information on that server. so how can i so that job in RoR?

give me a help please!

thanks and regards.
Amjith PS

removed_email_address@domain.invalid
+91 9388880335


#2

Hi Amjith,

Ruby (the language) gives you a few possibilities for connecting to a
remote server. For your needs you’ll probably want Net::HTTP, also
check out the excellent open-uri. Both are included in the standard
Ruby dist, so just do:

require ‘rubygems’
require ‘open-uri’

thepage = open(‘http://someurl.com/mypage’)

Rails (the framework) also comes with a library for consuming REST
based webservices, so if that’s your thing you should check it out,
it’s called active_resource.

/Jonas

P.S.: Some years ago two guys called Larry and Sergei started a rather
nifty website which helps in researching this sort of thing. Can’t
seem to remember the name, has a lot of o’s in it though.