Amazon MWS php产品Api集成

Amazon MWS php产品Api集成,php,amazon-web-services,amazon-mws,Php,Amazon Web Services,Amazon Mws,我正在尝试开发一个支持我在亚马逊业务的应用程序。为此,我想从我的产品的重新定价系统开始,它会自动改变亚马逊的价格 但我对Amazon MWS的集成有问题。为了得到第一个结果,我加载了Amazon产品库,并从“GetMyPriceForSKUSample”开始。 我将所有需要的信息都放在config.inc中。此外,我已经用MWS Scratchpad检查了所有的东西,它工作正常。在“GetMyPriceForSKUSample.php”中,我放了以下几行: $request->setSe


我正在尝试开发一个支持我在亚马逊业务的应用程序。为此,我想从我的产品的重新定价系统开始,它会自动改变亚马逊的价格
但我对Amazon MWS的集成有问题。为了得到第一个结果,我加载了Amazon产品库,并从“GetMyPriceForSKUSample”开始。 我将所有需要的信息都放在config.inc中。此外,我已经用MWS Scratchpad检查了所有的东西,它工作正常。在“GetMyPriceForSKUSample.php”中,我放了以下几行:

 $request->setSellerId(MERCHANT_ID);
 $request->setMarketplaceId(MARKETPLACE_ID);
 $request->setSellerSKUList("jb63anzugweiß150cm");
根据文件。我只想在屏幕上看到文章的数量,但我不确定我所做的是否正确。最后几行中的代码是我自己添加的。见下文

<?php
/*******************************************************************************
 * Copyright 2009-2017 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: 2017-03-22
 * Generated: Wed Mar 22 23:24:40 UTC 2017
 */

/**
 * Get My Price For SKU 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 Price For SKU Action
 ***********************************************************************/
 // @TODO: set request. Action can be passed as MarketplaceWebServiceProducts_Model_GetMyPriceForSKU
 $request = new MarketplaceWebServiceProducts_Model_GetMyPriceForSKURequest();
 $request->setSellerId(MERCHANT_ID);
 $request->setMarketplaceId(MARKETPLACE_ID);
 $request->setSellerSKUList("jb63anzugweiß150cm");
 // object or array of parameters
 invokeGetMyPriceForSKU($service, $request);

/**
  * Get Get My Price For SKU 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_GetMyPriceForSKU or array of parameters
  */

  function invokeGetMyPriceForSKU(MarketplaceWebServiceProducts_Interface $service, $request)
  {
      try {
        $response = $service->GetMyPriceForSKU($request);

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

        $dom = new DOMDocument();

        echo($response->toXML());
        $dom->loadXML($response->toXML());
        $dom->preserveWhiteSpace = false;
        $dom->formatOutput = true;

        //__ Added code_______________-
        echo "<br><br><br>";
        $domNote= $dom->getElementsByTagName('Amount');
        echo ($domNote->nodeValue);
        echo "<br><br><br>";
        //______________


        echo $dom->saveXML();
        $arro = $response->getGetMyPriceForSKUResult();


        //__ Added code_______________-
        echo "<pre>";
        print_r ($dom->getElementsByTagName("price"));
        print_r($dom);
        echo "</pre>";
        //______________


        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");
     }
 }
setSellerId(商户ID);
$request->setMarketplaceId(MARKETPLACE\u ID);
$request->setSellerSKUList(“jb63anzugweiß150cm”);
//对象或参数数组
invokeGetMyPriceForSKU($service,$request);
/**
*获取SKU行动样本的我的价格
*获取由标识的产品的竞争性定价和相关信息
*MarketplaceId和ASIN。
*
*@param MarketplaceWebServiceProducts_接口$MarketplaceWebServiceProducts_接口的服务实例
*@param mixed$request MarketplaceWebServiceProducts_Model_GetMyPriceForSKU或参数数组
*/
函数invokeGetMyPriceForSKU(MarketplaceWebServiceProducts_接口$service,$request)
{
试一试{
$response=$service->GetMyPriceForSKU($request);
echo(“服务响应”);
回声(“===============================================================================================================================\n”);
$dom=新的DOMDocument();
echo($response->toXML());
$dom->loadXML($response->toXML());
$dom->preserveWhiteSpace=false;
$dom->formatOutput=true;
//__添加代码_______________-
回声“


”; $domNote=$dom->getElementsByTagName('Amount'); echo($domNote->nodeValue); 回声“


”; //______________ echo$dom->saveXML(); $arro=$response->getGetMyPriceForSKUResult(); //__添加代码_______________- 回声“; 打印($dom->getElementsByTagName(“价格”); 打印(dom); 回声“; //______________ echo(“ResponseHeaderMetadata:”.$response->getResponseHeaderMetadata().“\n”); }捕获(MarketplaceWebServiceProducts_例外$ex){ echo(“捕获到的异常:”..ex->getMessage()。“\n”); echo(“响应状态代码:”..ex->getStatusCode()。“\n”); echo(“错误代码:”..ex->getErrorCode()。“\n”); echo(“错误类型:”..ex->getErrorType()。“\n”); echo(“请求ID:”..ex->getRequestId()。“\n”); echo(“XML:.$ex->getXML().“\n”); echo(“ResponseHeaderMetadata:”..ex->getResponseHeaderMetadata()。“\n”); } }
这就是结果

[第一张图片][1][1]:
[第二张图片][1][1]:
[第三张图片][1][1]:



谢谢你的帮助

我在PHP方面帮不了你太多,但是如果你使用MWS PHP工具包,你应该只需要插入你的凭证和SKU/ASIN

但是,如果您希望重新定价,请查看通知。您将从您产品的前20个报价中获得近乎实时的价格更新。然后,您几乎可以立即更新产品的价格