【问题标题】:amazon product advertising api get product with offers亚马逊产品广告 api 获取带有优惠的产品
【发布时间】:2015-09-13 15:31:36
【问题描述】:

我正在使用亚马逊产品广告 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);

}

}

任何帮助将不胜感激。

【问题讨论】:

  • “无法正常工作”是什么意思?您当前代码的输出/错误是什么?
  • 实际上此代码不返回有报价的产品。而我想要有优惠的产品。你有什么主意吗?对此问题的任何帮助将不胜感激!
  • 同样的问题。你解决了吗?

标签: php amazon-web-services amazon


【解决方案1】:

我知道它很晚,但我最近看到了这篇文章。

首先,您需要澄清您是如何向亚马逊产品广告 API 发出请求的,因为可能有多种原因,您没有得到正确的响应对象。 PHP Code base( previously ECS ) 可以帮助您正确启动。

关于优惠 - 当您收到“itemlookup”响应时,有“OfferSummary”和“Offers”键为您提供所请求产品(您已为其启动 itemLookup 的 ASIN)的可用优惠详情。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多