我正在尝试使用Amazon MWS api访问卖家的订单数据
我已经按照文档下载了订单API的PHP客户端库。
当我使用amazon scratchpad使用相同的信息时,我得到了正确的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:
1条答案
按热度按时间yjghlzjz1#
您的模拟服务正在覆盖生产服务示例。请参阅副本。
请删除第二个$服务并测试