您好,我正在使用亚马逊 MWS 报告 API 来列出库存,并且我已经成功下载了我的库存...但是 image-url 列下没有图像 url 它是制表符分隔的文件...
任何有报告 API 经验的人请帮助我...
$config = array (
'ServiceURL' => $serviceUrl,
'ProxyHost' => null,
'ProxyPort' => -1,
'MaxErrorRetry' => 3,
);
$service = new MarketplaceWebService_Client(
AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY,
$config,
APPLICATION_NAME,
APPLICATION_VERSION);
$reportId = '8890052323';
$parameters = array (
'Merchant' => MERCHANT_ID,
'Report' => @fopen('php://memory', 'rw+'),
'ReportId' => $reportId,
);
$request = new MarketplaceWebService_Model_GetReportRequest($parameters);
//$request = new MarketplaceWebService_Model_GetReportRequest();
$request->setMerchant(MERCHANT_ID);
$request->setReport(@fopen('php://memory', 'rw+'));
$request->setReportId($reportId);
invokeGetReport($service, $request);
function invokeGetReport(MarketplaceWebService_Interface $service, $request)
{
try {
$response = $service->getReport($request);
echo ("Service Response\n");
echo ("=============================================================================\n");
echo(" GetReportResponse\n");
if ($response->isSetGetReportResult()) {
$getReportResult = $response->getGetReportResult();
echo (" GetReport");
if ($getReportResult->isSetContentMd5()) {
echo (" ContentMd5");
echo (" " . $getReportResult->getContentMd5() . "\n");
}
}
if ($response->isSetResponseMetadata()) {
echo(" ResponseMetadata\n");
$responseMetadata = $response->getResponseMetadata();
if ($responseMetadata->isSetRequestId())
{
echo(" RequestId\n");
echo(" " . $responseMetadata->getRequestId() . "\n");
}
}
echo (" Report Contents\n");
$intry = (stream_get_contents($request->getReport()) . "\n");
file_put_contents('inventory.csv',$intry);
echo(" ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
} catch (MarketplaceWebService_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");
}
}