簡體   English   中英

亞馬遜產品廣告api獲取具有報價的產品

[英]amazon product advertising api get product with offers

我正在使用Amazon產品廣告API。 我想要獲得有報價的產品。

我嘗試了amazon-api php類來獲取數據,但是無法正常工作。

需要幫助才能獲得有報價的產品。

    <?php

    require_once 'aws_signed_request.php';

class AmazonProductAPI
    {

  private $public_key     = "YOUR AMAZON ACCESS KEY ID";
  private $private_key    = "YOUR AMAZON SECRET KEY";

/* 'Associate Tag' now required, effective from 25th Oct. 2011 */
private $associate_tag  = "YOUR AMAZON ASSOCIATE TAG";

const MUSIC = "Music";
const DVD   = "DVD";
const GAMES = "VideoGames";

  private function verifyXmlResponse($response)
   {
    if ($response === False)
    {
        throw new Exception("Could not connect to Amazon");
    }
    else
    {
        if (isset($response->Items->Item->ItemAttributes->Title))
        {
            return ($response);
        }
        else
        {
            throw new Exception("Invalid xml response.");
        }
    }
    }

  private function queryAmazon($parameters)
   {
    return aws_signed_request("com",
                              $parameters,
                              $this->public_key,
                              $this->private_key,
                              $this->associate_tag);
}

public function searchProducts($search,$category,$searchType="UPC")
{
    $allowedTypes = array("UPC", "TITLE", "ARTIST", "KEYWORD");
    $allowedCategories = array("Music", "DVD", "VideoGames");

    switch($searchType) 
    {
        case "UPC" :
            $parameters = array("Operation"     => "ItemLookup",
                                "ItemId"        => $search,
                                "SearchIndex"   => $category,
                                "IdType"        => "UPC",
                                "ResponseGroup" => "Medium");
                        break;

        case "TITLE" :
            $parameters = array("Operation"     => "ItemSearch",
                                "Title"         => $search,
                                "SearchIndex"   => $category,
                                "ResponseGroup" => "Offers");
                        break;

    }

    $xml_response = $this->queryAmazon($parameters);

    return $this->verifyXmlResponse($xml_response);

}

}

任何幫助,將不勝感激。

我知道它已經很晚了,但是最近我才看到這個帖子。

首先,您需要弄清楚如何向亞馬遜產品廣告API發出請求,因為可能有多種原因,您沒有獲得正確的響應對象。 PHP代碼庫(以前為ECS)可以幫助您正確啟動。

關於商品-當您收到“ itemlookup”響應時,有鍵“ OfferSummary”和“ Offers”為您提供所請求產品的可用商品詳細信息(您已為其發起itemLookup的ASIN)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM