我已使用以下代码中的代码成功实施了亚马逊产品搜索:
I don't get prices with Amazon Product Advertising API
现在我正在尝试从亚马逊获取产品的当前价格。我只得到零售价。
例如,当我尝试使用amazon API获取产品价格http://www.amazon.com/gp/product/0743273567/ref=ox_sc_act_title_1?ie=UTF8&psc=1&smid=ATVPDKIKX0DER时,我得到以下值:
ListPrice] => Array
(
[0] => Array
(
[Amount] => 1500
[CurrencyCode] => USD
[FormattedPrice] => $15.00
)
)
....
[OfferSummary] => Array
(
[0] => Array
(
[LowestNewPrice] => Array
(
[0] => Array
(
[Amount] => 343
[CurrencyCode] => USD
[FormattedPrice] => $3.43
)
)
[LowestUsedPrice] => Array
(
[0] => Array
(
[Amount] => 250
[CurrencyCode] => USD
[FormattedPrice] => $2.50
)
)
[LowestCollectiblePrice] => Array
(
[0] => Array
(
[Amount] => 995
[CurrencyCode] => USD
[FormattedPrice] => $9.95
)
)
.....
[OfferListing] => Array
(
[0] => Array
(
[OfferListingId] => nmbRKFxxDoRqoOL8kMzXNMkb9X2XWMB44HkNuwC49%2F8Yfcc96dCsb3rHWjDaIQT9fWHO%2BUGNIXWaBug5raFqChfsnCsdiGqPu4F7x0PZSPByUJd5zQ%2BM0%2FuuINUX917HJRDhHGwa9HTfCSlqfJlAB5V62ZgCa%2FmY
[Price] => Array
(
[0] => Array
(
[Amount] => 343
[CurrencyCode] => USD
[FormattedPrice] => $3.43
)
)
[AmountSaved] => Array
(
[0] => Array
(
[Amount] => 1157
[CurrencyCode] => USD
[FormattedPrice] => $11.57
)
)
[PercentageSaved] => 77 .....
零售价: $ 15.00 可以在ListPrice参数中看到,但我无法在api响应中找到当前价格: $ 7.70 。
我还尝试了各种ResponseGroup,例如:Offers,OfferFull,Large,Medium等。
请帮帮我。 在此先感谢!
答案 0 :(得分:1)
这可能有点迟,但要获得当前价格,您需要包含商品响应组,然后从此节点获取当前价格
$price = htmlentities((string) $item->Offers->Offer->OfferListing->Price->Amount);
因为XML实际上看起来像这样
<Item>
<ASIN>B00KOKTZLQ</ASIN>
<OfferSummary>
<LowestNewPrice>
<Amount>3998</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$39.98</FormattedPrice>
</LowestNewPrice>
<TotalNew>4</TotalNew>
<TotalUsed>0</TotalUsed>
<TotalCollectible>0</TotalCollectible>
<TotalRefurbished>0</TotalRefurbished>
</OfferSummary>
<Offers>
<TotalOffers>1</TotalOffers>
<TotalOfferPages>1</TotalOfferPages>
<MoreOffersUrl>
https://www.amazon.com/gp/offer-listing/B00KOKTZLQ/?&AWSAccessKeyId=[Your_AWSAccessKeyID]&ie=UTF8&tag=[Your_AssociateTag]%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB00KOKTZLQ
</MoreOffersUrl>
<Offer>
<OfferAttributes>
<Condition>New</Condition>
</OfferAttributes>
<OfferListing>
<OfferListingId>
LYcccWDl3oNWXKkngMuydLjjKXsOR4AO2tGTdMW%2BNOA%2F%2FV61ektF%2FstkahL39vySB75wmcQJ7lsWOW3NAjVZpwgnQnxZE62sf%2B34NWSBuAzkkR7lCjtGLXn0aFfQ5KAGmNFYzScqWHSecKmnMA%2BuBA%3D%3D
</OfferListingId>
<Price>
<Amount>6000</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$60.00</FormattedPrice>
</Price>
<SalePrice>
<Amount>4495</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$44.95</FormattedPrice>
</SalePrice>
<AmountSaved>
<Amount>1505</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$15.05</FormattedPrice>
</AmountSaved>
<PercentageSaved>25</PercentageSaved>
<Availability>Usually ships in 1-2 business days</Availability>
<AvailabilityAttributes>
<AvailabilityType>now</AvailabilityType>
<MinimumHours>24</MinimumHours>
<MaximumHours>48</MaximumHours>
</AvailabilityAttributes>
<IsEligibleForSuperSaverShipping>0</IsEligibleForSuperSaverShipping>
<IsEligibleForPrime>0</IsEligibleForPrime>
</OfferListing>
</Offer>
</Offers>
</Item>
答案 1 :(得分:0)
从amazon docs开始,它表示Operation=ItemLookup
会返回产品数据,并且您会从该回复中获得<LowestNewPrice><Amount>
代码,该代码会为您提供所请求商品的最新价格。所以请参考亚马逊提供的文件。
希望这会对你有所帮助。
谢谢!
答案 2 :(得分:0)
您可以轻松获得响应组的价格,例如: responseGroup( '中,OfferSummary,VariationSummary')
关键:VariationSummary有一个你可以找到的对象:
请注意,您可能无法在variationSummery对象中获得以上所有价格参数,因此请进行相应的检查。