使用 PHP 从亚马逊 MWS API 获取订单数据

Get Orders data from Amazon MWS API using PHP

我正在尝试使用 Amazon MWS api
访问卖家的订单数据 我已经按照文档下载了订单 PHP 客户端库 API。
当我使用相同信息使用亚马逊暂存器时,我在 XML 中得到了正确的订单列表,但是当我尝试使用 PHP 客户端库执行此操作时,我没有得到任何 XML输出,而不是我得到纯字符串。

代码

  #ListOrdersSample.php   #Page

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


$serviceUrl = "https://mws.amazonservices.in/Orders/2013-09-01";

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

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

  $service = new MarketplaceWebServiceOrders_Mock();

 $request = new MarketplaceWebServiceOrders_Model_ListOrdersRequest();
 $request->setSellerId(MERCHANT_ID);
 $request->setCreatedAfter('2018-08-01');

 invokeListOrders($service, $request);

   function invokeListOrders(MarketplaceWebServiceOrders_Interface $service, 
$request)
  {
      try {
        $response = $service->ListOrders($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 (MarketplaceWebServiceOrders_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");
     }
 }

在 运行 这个脚本上我得到的输出是:

Service Response    
====================================================================== 
String 1969-07-21T02:56:03Z 1969-07-21T02:56:03Z String String 1969-07- 
21T02:56:03Z 1969-07-21T02:56:03Z String String String String String String 
String String String String String String String String String String String 
String String 1 1 String String String String String String String String 
String String String String String String true String String String 1969-07- 
21T02:56:03Z 1969-07-21T02:56:03Z 1969-07-21T02:56:03Z 1969-07-21T02:56:03Z 
true String true true String true 1969-07-21T02:56:03Z true String 
ResponseHeaderMetadata: 

您模拟服务正在覆盖生产服务实例。查看副本。

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

 $service = new MarketplaceWebServiceOrders_Mock();

请删除第二个 $service 并进行测试