function amazon_convert_to_asin in Amazon Product Advertisement API 6
Same name and namespace in other branches
- 7.2 amazon.module \amazon_convert_to_asin()
- 7 amazon.module \amazon_convert_to_asin()
Try to turn a non-asin into an ASIN where possible.
If the received input appears to be an EAN (ISBN-13) or an Amazon.com/de/uk link, then this tries to convert it into an ASIN.
Parameters
$input:
Return value
An ASIN if possible. Otherwise whatever was passed in, after removing dashes.
5 calls to amazon_convert_to_asin()
- amazon_test_form_submit in ./
amazon.admin.inc - asin_text_process in asin/
asin.module - Process an individual element.
- asin_token_values in asin/
asin.module - Implementation of hook_token_values()
- _amazon_filter_process_text in amazon_filter/
amazon_filter.module - _asin_load_items in asin/
asin.module - Get an array of items from Amazon.com.
File
- ./
amazon.module, line 650
Code
function amazon_convert_to_asin($input) {
$input = preg_replace('/-/', '', $input);
// Remove dashes.
if (preg_match('/^https?:/', $input)) {
$parts = preg_split('/\\//', $input);
$asin = $parts[5];
// 6th section of split, right after /dp/
return $asin;
}
// Attempt conversion of 13-digit ASIN by doing an Amazon lookup.
if (strlen($input) == 13 && is_numeric($input)) {
$asin = amazon_ean_to_asin($input);
return $asin;
}
return $input;
}