My Rails app. needs to retrieve XML statistical data from another site''s API. To get the XML page, I need to POST the username and password and date for the stats. So far I have managed to do this: within my app, I created a form with the (hidden) username, password, date and post it to the proper url... this causes my brower to redirect to the API page and sure enough I see the XML. Then I copy the XML, go BACK (with my browser)to my app, and I paste it into a textbox in my app. I submit this and I am able to properly parse the XML. What I can''t figure out is this: how do I get my app to automatically retrieve the XML so that I don''t have to cut and paste it? Any help would be appreciated! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You have the form post back you your app, which takes the login data and wgets (Net::HTTP, or what not) the XML for itself. Jason On 5/31/07, Tenzing Kernan < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > My Rails app. needs to retrieve XML statistical data from another site''s > API. To get the XML page, I need to POST the username and password and > date for the stats. > > So far I have managed to do this: > within my app, I created a form with the (hidden) username, password, > date and post it to the proper url... this causes my brower to redirect > to the API page and sure enough I see the XML. > > Then I copy the XML, go BACK (with my browser)to my app, and I paste it > into a textbox in my app. I submit this and I am able to properly parse > the XML. > > What I can''t figure out is this: > how do I get my app to automatically retrieve the XML so that I don''t > have to cut and paste it? Any help would be appreciated! > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jason Roelofs wrote:> You have the form post back you your app, which takes the login data and > wgets (Net::HTTP, or what not) the XML for itself. > > JasonThanks for the info Jason. At least I know which direction to look now. I didn''t quickly find much documentation on ''wgets'', but have time to look later tomorrow. I do have a few things I am wondering about now: 1. the API I need to access will not work unless I POST the parameters to it. Can I include POST data in the wgets function call? 2. Can anyone recommend a book with good details about doing this? Thanks All! - Tenzing -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
# I got it! the_url = ''http://www.the_data.com/report.php'' user_name = ''joeshmo'' password = ''happy'' date = ''2007-06-01'' res = Net::HTTP.post_form(URI.parse(the_url), {:user_name => user_name, :password => password, :date => date}) parse_this_xml = res.body #Thanks for the clue Jason! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---