简体   繁体   中英

Rails + Amazon API + Integration

I'm a rails newb - in a little over my head and could use some help.

I have an existing rails app, and I'm trying to integrate the Amazon Products API with the gem "ruby-aaws"....ie, place items inside a model, show them in the view, etc.

I've never worked with an external API before, so I'm not sure where to begin to start integration. Any help at all is much appreciated!

Here is some of the code that I've used to pull data with the API:

require 'amazon/aws'
require 'amazon/aws/search'

include Amazon::AWS
include Amazon::AWS::Search

is = ItemSearch.new( 'Watches', { 'Keywords' => 'Gucci' } )
rg = ResponseGroup.new( 'Large' )

req = Request.new
req.locale = 'us'

resp = req.search( is, rg )

items = resp.item_search_response[0].items[0].item

# Available properties for first item:
#
puts items[0].properties

items.each do |item|
  attribs = item.item_attributes[0]
  puts attribs.label
  if attribs.list_price
    puts attribs.title, attribs.list_price[0].formatted_price, item.medium_image, ''
  end
end

I am also a newbie and trying to do something similar. I found this example on GitHub that looks really promising.

https://github.com/hundredwatt/Amazon-Product-Search-Example

But there are also some great related questions here that have answers for you:

Ruby Amazon book search

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM