【问题标题】:How to retrieve the amazon api product price only for amazon merchantID如何仅检索亚马逊商家 ID 的亚马逊 api 产品价格
【发布时间】:2017-03-10 09:06:08
【问题描述】:

这是我的代码,但它返回第三方卖家的最低价格,我做错了什么?我正在使用响应组 Offers,因为它似乎是根据文档获得结果的方式。

function getAmazonPrice($region, $asin) {

    $xml = aws_signed_request($region, array(
        "Operation" => "ItemLookup",
        "ItemId" => $asin,
        "IncludeReviewsSummary" => False,
        "ResponseGroup" => "Medium, Offers",
        "MerchantId" => "Amazon",
    ));

    $item = $xml->Items->Item;
    $title = htmlentities((string) $item->ItemAttributes->Title);
    $url = htmlentities((string) $item->DetailPageURL);
    $image = htmlentities((string) $item->MediumImage->URL);
    $price = htmlentities((string) $item->OfferSummary->LowestNewPrice->Amount);
    $code = htmlentities((string) $item->OfferSummary->LowestNewPrice->CurrencyCode);
    $qty = htmlentities((string) $item->OfferSummary->TotalNew);

    if ($qty !== "0") {
        $response = array(
            "code" => $code,
            "price" => number_format((float) ($price / 100), 2, '.', ''),
            "image" => $image,
            "url" => $url,
            "title" => $title
        );
    }

    return $response;
}

【问题讨论】:

    标签: php amazon-product-api


    【解决方案1】:

    我也有同样的问题。

    我所做的是假设当亚马逊提供折扣时,它是在 SalePrice 中:

    $SalePrice=$xmlProduct->Items->Item->Offers->Offer->OfferListing->SalePrice->Amount;

    如果该节点不存在,则没有折扣,只需使用上市价格: $xmlProduct->Items->Item->Offers->Offer->OfferListing->Price->Amount

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-03
      相关资源
      最近更新 更多