skip to Main Content

I am building a small webapp with PHP and jlevers/selling-partner-api (https://github.com/jlevers/selling-partner-api).
I need to recover the ASIN starting from EAN code.

I have tried this:

$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());
}

but i receive this strange error:

SellingPartnerApiSellerCatalogItemsV20220401Api::getCatalogItem():
Argument #1 ($asin) must be of type string, array given

2

Answers


  1. Chosen as BEST ANSWER

    i have try to change the code as you suggest:

        $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());
    }
    

    but now the error is:

    Array to string conversion, ithink that something is wrong in the API


  2. As per Amazon searchCatalogItem API call, the identifiers parameter is:

    A comma-delimited list of product identifiers to search the Amazon catalog for.

    Hence you will need change your code, in order to set the identifiers as a string (not as an array of strings). In case you need to ask for more than 1 EAN, just set that parameter with a comma-separated list of EAN codes.

    Warning: a maximum of 20 identifiers may be specified in the identifiers parameter.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search