我正在使用 PHP 和 jlevers/ sell-partner-api 构建小型网络应用程序 (https://github.com/jlevers/ sell-partner-api)。 我需要从 EAN 代码开始恢复 ASIN。
我已经尝试过这个:
$catalogApi = $connector->catalogItems();
try {
// EAN code of a product
$ean = '3578830113254';
$marketplaceId = 'APJ6JRA9NG5V4';
$includedData = ["summaries", "images", "salesRanks", "productTypes", "identifiers", "variations"];
//search EAN
$response = $catalogApi->searchCatalogItems([
'marketplaceIds' => [$marketplaceId],
'identifiersType' => 'EAN',
'identifiers' => [$ean],
'includedData' => $includedData
]);
// Visualizza la risposta
echo "<pre>";
print_r($response);
echo "</pre>";
} catch (\Exception $e) {
// Gestisci gli errori
echo "Errore: ";
var_dump($e->getMessage());
}
但是我收到了这个奇怪的错误:
SellingPartnerApi\Seller\CatalogItemsV20220401\Api::getCatalogItem():参数 #1 ($asin) 必须是字符串类型,给定数组
searchCatalogItem
API 调用,identifiers
参数为:
用于在亚马逊目录中搜索的以逗号分隔的产品标识符列表。
因此,您需要更改代码,以便将
identifiers
设置为字符串(而不是字符串数组)。如果您需要请求超过 1 个 EAN,只需使用逗号分隔的 EAN 代码列表来设置该参数即可。
警告:在
identifiers
参数中最多可以指定20个标识符。