Several of our customers have a shop on Amazon or Ebay. Thus a lot of our development services include official web services like the Amazon MWS and AWS API.
Usually products on these platforms have their own identifiers in the respective system. On Amazon, each product's identifier is called the Amazon Standard Identification Number (ASIN).
It is quite often necessary to convert this Amazon based identifier (ASIN) to a global identifier such as EAN (European Article Number or International Article Number) to provide further processing of other applications.
There are several tools out there providing the necessary function to convert a given ASIN to an EAN. These are mainly installable tools like ASIN to EAN Converter, free online tools like erwinmayer.com or even paid services.
These online tools are lacking an API so they are not easily able to integrate into your web application. The answer to the problem is easier than one might first think. Amazon Web Services AWS already provide the functionality to convert an ASIN to EAN - even if it is not that obvious.
Using a library like http://www.ulrichmierendorff.com/software/aws_hmac_signer.html you can perform a signed request to the AWS API.
include"aws_signed_request.php";
Now you can make an ItemLookup Request to the Amazon AWS API using the ASINwhich you want to convert and extract the respective EAN from the API response.
ASIN2EAN function
functionASINtoEAN($asin,$locale="de") {
//Amazon AWS data
$AWSAccessKeyId= "YourKeyID";
$AWSSecretKey= "YourSecretKey";
$associateTag= "YourAssociateTag";
$request= array("Operation"=>"ItemLookup", "ItemId"=>$asin,
"ResponseGroup"=>"ItemAttributes");
$signedRequest= aws_signed_request($locale, $request,
$AWSAccessKeyId, $AWSSecretKey, $associateTag);
//call curl
$curl= curl_init($signedRequest);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response= curl_exec($curl);
curl_close($curl);
//handle response
if($response=== FALSE){
returnnull;}else {
$xml= simplexml_load_string($response);
if($xml=== FALSE)
returnnull; //no xml
else {
if(isset($xml->Items->Request->Errors)) //ASIN was not found or different error
returnnull;
else
return$xml->Items->Item->ItemAttributes->EAN;
}}}
You can get necessary credentials after registering for the Amazon Web Services AWS .
For any questions or thoughts feel free to contact us through your preferred channel.
18 June 2020