1
我是一個rails新手 - 在一點點在我的頭上,可以使用一些幫助。Rails +亞馬遜API +集成
我有一個現有的Rails應用程序,我正在嘗試將Amazon產品API與寶石「ruby-aaws」集成....即將項目放入模型中,在視圖中顯示它們等。
我從來沒有使用過外部API,所以我不知道從哪裏開始集成。任何幫助都非常感謝!
下面是一些我已經使用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