On 20 Nov 2008, at 09:38, Max Williams wrote:
> > Thanks Fred > > I'm not having any luck with it so far - this is the curl call i was > making (with some changes to protect the innocent): > > curl http://www.l-mail.biz/scripts/lia/lia.php \ > -d l_cid='1106' \ > -d l_key='cg3608898b74a4c688787ab479b8bb9f' \ > -d > l_content='http://ir.chazanga.com/letter/show?encoded=MTE4MiZpdCdzIHdlZG5lc2RheQ==' > \ > -d l_pb_url='http://ir.chazanga.com/letter/confirm' \ > -d l_sname='chazanga' \ > -d l_rname='Max Williams' \ > -d l_rcname='chazanga' \ > -d l_raddress1='Suites 17 & 18' \ > -d l_raddress2='9-12 Middle Street' \ > -d l_rcity='Brighton' \ > -d l_rpostcode='BN1 3TN' \ > -d l_rcountry='3' \ > -d l_email='[EMAIL PROTECTED]' \ > -d l_fb_emails='1' \ > -d p_user_id='2054' > > So, when i tried to use Net::HTTP i was trying to deal with this > massive > params string. I split it up like so: > > domain = "www.l-mail.biz" > > path = "/scripts/lia/lia.php" > > params = > "l_cid=1106&l_key=cg3608898b74a4c688787ab479b8bb9f&l_content=http://ir.chazanga.com/letter/show?encoded=MTE4MiZpdCdzIHdlZG5lc2RheQ==&l_pb_url=http://ir.chazanga.com/letter/confirm&l_sname=chazanga&l_rname=Max-Williams&l_rcname=chazanga&l_raddress1=Suites-17-18&l_raddress2=9-12-Middle-Street&l_rcity=Brighton&l_rpostcode=BN1-3TN&l_rcountry=3&[EMAIL > PROTECTED]&l_fb_emails=1&p_user_id=2054 > " > > The params string had spaces and & signs in it, so i just replaced > them > with safe characters temporarily while i played with Net::HTTP (with > escaping them properly down for a later task). > > I tried this: > > http = Net::HTTP.new("#{domain}") > headers, body = http.get("#{path}?#{params}") Yuck. would be a lot easier to take a hash of params (ie {'l_cid' => '1106', 'l_key' => 'cg3608898b74a4c688787ab479b8bb9f', ...} and then call to_query on it. Net::HTTP will also do that for you, with something like response = Net::HTTP.start(host, port) do |http| get = Net::HTTP::Get.new path get.form_data = some_hash get.content_type = "application/x-www-form-urlencoded" http.request get end Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---