提交亚马逊MWS GetMyFeesEstimate API请求

时间:2016-12-06 19:03:36

标签: php amazon-mws

我尝试使用亚马逊MWS API检索特定SKU的费用估算值。我有样本文件并已阅读和阅读但我无法弄清楚如何实际指定提交的SKU。

我有针对模拟文件的示例文件GetMyFeesEstimateSample.php,但这是响应文件,不是吗?

以下是我的内容,如何为请求指定SellerSKU?

<?php
/*******************************************************************************
 * Copyright 2009-2016 Amazon Services. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 *
 * You may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 * specific language governing permissions and limitations under the License.
 *******************************************************************************
 * PHP Version 5
 * @category Amazon
 * @package  Marketplace Web Service Products
 * @version  2011-10-01
 * Library Version: 2016-06-01
 * Generated: Fri Sep 16 11:49:32 PDT 2016
 */

/**
 * Get My Fees Estimate Sample
 */

require_once('.config.inc.php');

/************************************************************************
 * Instantiate Implementation of MarketplaceWebServiceProducts
 *
 * AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY constants
 * are defined in the .config.inc.php located in the same
 * directory as this sample
 ***********************************************************************/
// More endpoints are listed in the MWS Developer Guide
// North America:
//$serviceUrl = "https://mws.amazonservices.com/Products/2011-10-01";
// Europe
//$serviceUrl = "https://mws-eu.amazonservices.com/Products/2011-10-01";
// Japan
//$serviceUrl = "https://mws.amazonservices.jp/Products/2011-10-01";
// China
//$serviceUrl = "https://mws.amazonservices.com.cn/Products/2011-10-01";


 $config = array (
   'ServiceURL' => $serviceUrl,
   'ProxyHost' => null,
   'ProxyPort' => -1,
   'ProxyUsername' => null,
   'ProxyPassword' => null,
   'MaxErrorRetry' => 3,
 );

 $service = new MarketplaceWebServiceProducts_Client(
        AWS_ACCESS_KEY_ID,
        AWS_SECRET_ACCESS_KEY,
        APPLICATION_NAME,
        APPLICATION_VERSION,
        $config);

/************************************************************************
 * Uncomment to try out Mock Service that simulates MarketplaceWebServiceProducts
 * responses without calling MarketplaceWebServiceProducts service.
 *
 * Responses are loaded from local XML files. You can tweak XML files to
 * experiment with various outputs during development
 *
 * XML files available under MarketplaceWebServiceProducts/Mock tree
 *
 ***********************************************************************/
 // $service = new MarketplaceWebServiceProducts_Mock();

/************************************************************************
 * Setup request parameters and uncomment invoke to try out
 * sample for Get My Fees Estimate Action
 ***********************************************************************/
 // @TODO: set request. Action can be passed as MarketplaceWebServiceProducts_Model_GetMyFeesEstimate
 $request = new MarketplaceWebServiceProducts_Model_GetMyFeesEstimateRequest();
 $request->setSellerId(MERCHANT_ID);
 // object or array of parameters
 invokeGetMyFeesEstimate($service, $request);

/**
  * Get Get My Fees Estimate Action Sample
  * Gets competitive pricing and related information for a product identified by
  * the MarketplaceId and ASIN.
  *
  * @param MarketplaceWebServiceProducts_Interface $service instance of MarketplaceWebServiceProducts_Interface
  * @param mixed $request MarketplaceWebServiceProducts_Model_GetMyFeesEstimate or array of parameters
  */

  function invokeGetMyFeesEstimate(MarketplaceWebServiceProducts_Interface $service, $request)
  {
      try {
        $response = $service->GetMyFeesEstimate($request);

        echo ("Service Response\n");
        echo ("=============================================================================\n");

        $dom = new DOMDocument();
        $dom->loadXML($response->toXML());
        $dom->preserveWhiteSpace = false;
        $dom->formatOutput = true;
        echo $dom->saveXML();
        echo("ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");

     } catch (MarketplaceWebServiceProducts_Exception $ex) {
        echo("Caught Exception: " . $ex->getMessage() . "\n");
        echo("Response Status Code: " . $ex->getStatusCode() . "\n");
        echo("Error Code: " . $ex->getErrorCode() . "\n");
        echo("Error Type: " . $ex->getErrorType() . "\n");
        echo("Request ID: " . $ex->getRequestId() . "\n");
        echo("XML: " . $ex->getXML() . "\n");
        echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
     }
 }

我发现了这个,但我仍然不知道该怎么做。您认为亚马逊样本会包含样本ASIN或SKU; https://docs.developer.amazonservices.com/en_US/products/Products_GetMyFeesEstimate.html

Get Fees

2 个答案:

答案 0 :(得分:4)

昨天正在编程并找到解决方案,有关FeesEstimateRequestElements的更多信息:

http://docs.developer.amazonservices.com/en_US/products/Products_Datatypes.html#FeesEstimateRequest

有关GetMyFeesEstimate操作的信息:

http://docs.developer.amazonservices.com/en_US/products/Products_GetMyFeesEstimate.html

GetMyFeesEstimateSample带有一些注释,这有效:

<Button  
    android:id="@+id/MyButton"
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/Hello"
    />

答案 1 :(得分:2)

作为您的请求的一部分,您提交了FeesEstimateRequestList在该列表中,您指定了IdType,可以是ASINSellerSKU。然后在IdValue中给它一个值。请注意,还需要其他元素。在这里查看FeesEstimateRequest这些元素https://docs.developer.amazonservices.com/en_US/products/Products_Datatypes.html#FeesEstimateRequest

上面的POST为[{1}}定义了ASIN而不是SellerSKU。如上所述,只需将其更改为IdType即可设置。

我使用C# SDK,其中包含所有这些示例。我认为PHP SDK会是相同的,但也许它是完整的。无论如何,您需要在POST中提交SellerSKU,以便MWS知道您在寻找什么。

相关问题