我已經創建了amazon賣家帳戶,並且我已經註冊了mws(市場網絡服務),並且我獲得了所有密鑰,例如密鑰,訪問密鑰和所有密鑰。 現在我下載了第一個amazon命令api,它帶有一組文件。 在.config.inc.php
我給所有的憑據,他給了樣本文件夾下的一些示例代碼中,首先我打開GetOrderSample.php
和註釋掉服務URL爲$serviceUrl = "https://mws.amazonservices.com/Orders/2013-09-01";
我在瀏覽器中運行該文件後,它說:捕獲異常:在亞馬遜訂單API中拒絕訪問
「中招異常:訪問被拒絕響應狀態代碼:401錯誤代碼:存取遭拒錯誤類型:發件人請求ID:606e9ead-fb70-4a60-a795-4fc601421c65 XML:發件人存取遭拒」
請幫我解決這個即時通訊停留在此很長一段時間的地方。 這是GetOrderSample.php的文件代碼,
<?php
/*******************************************************************************
* Copyright 2009-2015 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 Orders
* @version 2013-09-01
* Library Version: 2015-09-24
* Generated: Fri Sep 25 20:06:28 GMT 2015
*/
/**
* Get Order Sample
*/
require_once('.config.inc.php');
/************************************************************************
* Instantiate Implementation of MarketplaceWebServiceOrders
*
* 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/Orders/2013-09-01";
// Europe
//$serviceUrl = "https://mws-eu.amazonservices.com/Orders/2013-09-01";
// Japan
//$serviceUrl = "https://mws.amazonservices.jp/Orders/2013-09-01";
// China
//$serviceUrl = "https://mws.amazonservices.com.cn/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);
/************************************************************************
* Uncomment to try out Mock Service that simulates MarketplaceWebServiceOrders
* responses without calling MarketplaceWebServiceOrders service.
*
* Responses are loaded from local XML files. You can tweak XML files to
* experiment with various outputs during development
*
* XML files available under MarketplaceWebServiceOrders/Mock tree
*
***********************************************************************/
// $service = new MarketplaceWebServiceOrders_Mock();
/************************************************************************
* Setup request parameters and uncomment invoke to try out
* sample for Get Order Action
***********************************************************************/
// @TODO: set request. Action can be passed as MarketplaceWebServiceOrders_Model_GetOrder
$request = new MarketplaceWebServiceOrders_Model_GetOrderRequest();
$request->setSellerId(MERCHANT_ID);
// object or array of parameters
invokeGetOrder($service, $request);
/**
* Get Get Order Action Sample
* Gets competitive pricing and related information for a product identified by
* the MarketplaceId and ASIN.
*
* @param MarketplaceWebServiceOrders_Interface $service instance of MarketplaceWebServiceOrders_Interface
* @param mixed $request MarketplaceWebServiceOrders_Model_GetOrder or array of parameters
*/
function invokeGetOrder(MarketplaceWebServiceOrders_Interface $service, $request)
{
try {
$response = $service->GetOrder($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");
}
}
向我們顯示代碼。 – Raf
我已編輯我的帖子和代碼在那 –
請any1幫我在這.. –