Oops, sorry forgot CODE tags...
One more CBA fix to add to anyone still striving - there's hope, it works fine for us now.
We were running into the dreaded "We're sorry, but..." message after login to Amazon. Our problem was that sometimes accented characters - greater than 127 ASCII - were in some product names. Amazon choked on these. To fix:
In button_generator.php, fix characters in the title:
Change:
Code:
$xmlBuilder->Element('Title', substr($item[name], 0, MAX_TITLE_LEN));
to:
Code:
$xmlBuilder->Element('Title', cleanupTextForAmazon(substr($item[name], 0, MAX_TITLE_LEN)));
Then use your favorite code to cleanup om cleanupTextForAmazon function at top of same module, outside the class. My sledgehammer looks like this:
Code:
function cleanupTextForAmazon($text)
{
// First, replace UTF-8 characters.
$text = str_replace(
array("\xe2\x80\x98", "\xe2\x80\x99", "\xe2\x80\x9c", "\xe2\x80\x9d", "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x80\xa6"),
array("'", "'", '"', '"', '-', '--', '...'),
$text);
// Next, replace their Windows-1252 equivalents.
$text = str_replace(
array(chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(133)),
array("'", "'", '"', '"', '-', '--', '...'),
$text);
// Then fix accents
$text = strtr($text,'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ','aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
// Now, get rid of all unprintable
$text = preg_replace( '/[^[:print:]]/', '',$text);
return $text; // squeaky clean for Amazon!
}
Bookmarks