亚马逊市场PHP获取订单API

时间:2016-04-30 11:52:19

标签: amazon-web-services amazon amazon-mws

我使用了AMAZON MWS Marketplace网络服务订单Get Order API .. 我已正确配置。但收到错误,如“捕获异常:访问被拒绝响应状态代码:401错误代码:AccessDenied错误类型:发件人请求ID:9bc2e235-218c-4245-b63e-7d93bc6f1da0 XML:发件人AccessDenied访问被拒绝9bc2e235-218c-4245 -b63e-7d93bc6f1da0 ResponseHeaderMetadata:的requestId:9bc2e235-218c-4245-b63e-7d93bc6f1da0,ResponseContext:98sqo3AP9MOvPqqfRnPTHw15yXGOIPaK8j3OBLilY + Fp的// ta5MYQwxJaYrV7AZLBcei5I2EWYJoq 53tbCvpcJQ ==,时间戳:2016-04-30T11:20:03.130Z,配额最大:,配额剩余: ,配额重置为:

我的代码低于

public function list_of_order_items()
{

    include_once (DOCROOT."application/vendor/amazon-mws-sdk-master/lib/MarketplaceWebServiceOrders/Samples/config.inc.php");       

     $config = array (
        'ServiceURL' => "https://mws.amazonservices.com/Orders/2013-09-01",
        '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);

        $request = new MarketplaceWebServiceOrders_Model_GetOrderRequest();
        $request->setSellerId(MERCHANT_ID);
        // object or array of parameters

        $response = $this->invokeGetOrder($service, $request);

}

public function invokeGetOrder(MarketplaceWebServiceOrders_Interface $service, $request)

{

  try {
    $response = $service->GetOrder($request);

回声“

"; print_r($response); exit;
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"); }

}

1 个答案:

答案 0 :(得分:0)

我认为你错过了为$ request对象配置订单ID参数。

$request->setAmazonOrderId($orderId);