I''ve been having a play with eBay and PayPal API calls and am happily getting xml responses using Net::HTTP calls but now I''m wondering if I can use ActiveResource instead. I''ve created a very basic ActiveResource class that has self.site set to a full url that returns xml data in a browser window e.g. http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&GLOBAL-ID=EBAY-GB&SERVICE_VERSION=1.1.0&SECURITY-APPNAME=xxxxxxxxxxxxxxxxx&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&keywords=bike&paginationInput.pageNumber=1&paginationInput.entriesPerPage=5 So I have a very basic active resource class that looks like this class EbayResource < ActieResource::Base self.site "http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&GLOBAL-ID=EBAY-GB&SERVICE_VERSION=1.1.0&SECURITY-APPNAME=xxxxxxxxxxxxxxxxx&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&keywords=bike&paginationInput.pageNumber=1&paginationInput.entriesPerPage=5" end From the console I just try calling .find(:all) and .get(:all) but get 302 redirected responses with page not found messages. Like I say with the correct SECURITY-APPNAME param set it works fine in a browser just not from an ActiveResource class. Obviously I could be doing this totally wrong and searching through railscasts, Rails docs and other resources has turned up noting that I can make any sense of and it makes me wonder if ActiveResource is suitable for non REST style api calls. Any pointers would be greatly appreciated. Thanks James -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Lasse Bunk
2010-Feb-14 13:46 UTC
Re: Is ActioveResource suitable for use eBay/PayPal api''s?
From this page: http://www.therailsway.com/2007/9/3/using-activeresource-to-consume-web-services> > 1. The service must understand Rails-style REST URLs. (e.g. “POST > /credit_cards.xml” to create a credit card, etc.) > 2. The service must respond with a single XML-serialized object > (Rails-style). > 3. The service must make appropriate use of HTTP status codes (404 if > the requested record cannot be found, 422 if any validations fail, etc.). > >2010/2/14 James West <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>> I''ve been having a play with eBay and PayPal API calls and am happily > getting xml responses using Net::HTTP calls but now I''m wondering if I > can use ActiveResource instead. > > I''ve created a very basic ActiveResource class that has self.site set to > a full url that returns xml data in a browser window > > e.g. > > > http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&GLOBAL-ID=EBAY-GB&SERVICE_VERSION=1.1.0&SECURITY-APPNAME=xxxxxxxxxxxxxxxxx&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&keywords=bike&paginationInput.pageNumber=1&paginationInput.entriesPerPage=5 > > So I have a very basic active resource class that looks like this > > class EbayResource < ActieResource::Base > self.site > " > http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&GLOBAL-ID=EBAY-GB&SERVICE_VERSION=1.1.0&SECURITY-APPNAME=xxxxxxxxxxxxxxxxx&RESPONSE-DATA-FORMAT=XML&REST-PAYLOAD&keywords=bike&paginationInput.pageNumber=1&paginationInput.entriesPerPage=5 > " > end > > From the console I just try calling .find(:all) and .get(:all) but get > 302 redirected responses with page not found messages. > > Like I say with the correct SECURITY-APPNAME param set it works fine in > a browser just not from an ActiveResource class. > > Obviously I could be doing this totally wrong and searching through > railscasts, Rails docs and other resources has turned up noting that I > can make any sense of and it makes me wonder if ActiveResource is > suitable for non REST style api calls. > > Any pointers would be greatly appreciated. > > Thanks > > James > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.