Monday, May 31, 2010

PHP: Amazon Store Manager / Freekrai.net

today i would like to mention a small problem with the Amazon Store Manager script available from Freekrai.net:

information in the readme.txt file reads: This program has been created by Roger Stringer and works with PHP4. since the introduction of the Amazon Product Advertising Service (formerly known as Amazon Web Services or Amazon E-Commerce Service [ECS], calls to amazon's server require a signed request. the Signature function hmac, however, only works with php5.

another requirement is that the php function allow url fopen must be set to On. to accomplish this simply create a php.ini file with the following line in it:
allow_url_fopen = On;
and save it to the store's root directory.

there is another small error in the aws4class.php5 file:
find
$ValueStringArray[] = "Timestamp=" .gmdate("Y-m-d\TH:i:s\Z");
(should be on line 258) and change it to
$ValueStringArray[] = "Timestamp=" .gmdate("Y-m-d\TH:i:s.000\Z");

should the script still not work you might have to follow the instructions about Troubleshooting in the readme.txt file
replacing
RewriteEngine On
with
Options +FollowSymlinks
RewriteEngine on
RewriteBase /AmazonStoreManager4/

in the .htaccess file, where in this example /AmazonStoreManager4/ is the scripts root directory.

these are all the basic changes i made to get the script to work.

enjoy!

tom.paine


Sunday, May 16, 2010

Software: Windows Install Clean Up

did you ever experience a problem while trying to install an iTunes update? i had this problem getting this error message that something was wrong with the Windows Installation Package. first i thought it had something to do with my QuickTime Registration Key for QuickTime Pro; however, it took me a while to sit down and try find out why this message always came up.

one day i un-installed (or tried to un-install) every Apple application on my computer (including the Safari Browser). i stumbled across a problem trying to un-install the Apple Software Update. when i checked the properties i found out that the folder where it was looking for a .msi file was empty.

some time ago i downloaded the Windows Install Clean Up tool from Microsoft, but never used it. searching the internet again for details on this issue i came across this article on the Apple support site: http://support.apple.com/kb/HT1926. it has a link to the Windows Install Clean Up software: http://support.microsoft.com/default.aspx?scid=kb;en-us;290301. there's a warning at the Microsoft site about the use of this tool. however, there's not much to go wrong. i followed the instructions from the Apple support page, starting the Windows Install Clean Up program a window opens that lists all the programs installed. next i selected Apple Software Update and pushed the remove button.

then i re-installed iTunes & QuickTime and the Safari Browser without any problems and any error messages. what i found interesting was that the Apple Software Update folder was now in a different place than where the system required it before for the iTunes update. Problem solved!

enjoy!

tom.paine


Sunday, May 02, 2010

PHP: Calin Uioreanu's amazon script

Amazon Web Services is a neverending story from transition to transition, that is:

it started of as Amazon Web Services, then became Amazon E-Commerce Service and is currently named Amazon Product Advertising.

in the process of keeping the various scripts i've either written myself or downloaded from different sites over the years running, i took up the amazon script from php9.com by Calin Uioreanu the other day. the website no longer seems to exist and through some new channels now available i was able to contact and inform him about the improvements i had been able to make to the script, which unfortunately i did not document. unfortunately because when Calin Uioreanu came back to me he replied that he had only little time now to play with it. he suggested that if i had a blog perhaps i could show the steps it took to get the script running again.

well, in the end i added a whole lot of other stuff to the script, that's why it's so hard for me to tell which changes i made just to get the basic script running. i'll try though to show just these steps.

persons long familiar and in touch with Amazon Web Services will know that the new version requires a SecretAccessKey in addition to the AWSAccessKeyID that was already required in the past. the user can obtain them by registering with aws.amazon.com. somewhere along the line there's something about fees being charged; however for our purpose to get this script going again it's still free of charge.

once the user has registered with aws.amazon.com and obtained the two keys mentioned above we place them into a separate file named #_aws_keys.inc.php5 (for example) like this:

<?php
$ACCESS_KEY_ID = "xxxxxxxxxxxxxxxxxxxx";
$SECRET_ACCESS_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
?>


and save this file into the common/ folder (for example).

now the trouble starts: i couldn't remember when to include the #_aws_keys.inc.php5 file. (having a good editor that can search through the files is always a good idea.) the #_aws_keys.inc.php5 is included in the product4.php5 file which we can find in the classes/ folder.

best is we now open the product4.php5 file and look for:

function getLiveSearch

then search for the following line:

$searchIndex = $missPlacedNodes[$_GET['browse']];

it should be Line 36. after the closing bracket Line 37 we now insert a whole bunch of code that already helps us to send a signed request to amazon.

here now is a big chunk of code that includes a few extras since i changed my script version to accomodate requests to all amazon locales:

if ($locale == 'US') { $site = 'com'; $partnerId = 'AFFILIATE ID FOR LOCALE US'; }
elseif ($locale == 'UK') { $site = 'co.uk'; $partnerId = 'AFFILIATE ID FOR LOCALE UK'; }
elseif ($locale == 'DE') { $site = 'de'; $partnerId = 'AFFILIATE ID FOR LOCALE DE'; }
elseif ($locale == 'JP') { $site = 'jp'; $partnerId = 'AFFILIATE ID FOR LOCALE JP'; }
elseif ($locale == 'FR') { $site = 'fr'; $partnerId = 'AFFILIATE ID FOR LOCALE FR'; }
elseif ($locale == 'CA') { $site = 'ca'; $partnerId = 'AFFILIATE ID FOR LOCALE CA'; }

include_once('common/#_aws_keys.inc.php5');

$timestamp = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z");
$timestamp = str_replace(':','%3A',$timestamp);

// This is needed for '+' added for space character in request
$requestparams='AWSAccessKeyId='.$ACCESS_KEY_ID.'&AssociateTag='.$partnerId.'&Operation=ItemSearch&SearchIndex='.$searchIndex.'&Keywords='.$searchString.'&ItemPage=1&ResponseGroup='.$responseGroup.'&Service=AWSECommerceService&Timestamp='.$timestamp.'&Version=2009-10-01';
$requestparams = str_replace('+','%2B',$requestparams);

$sort_requestparams = explode("&", $requestparams);
sort($sort_requestparams);

$request = "GET\necs.amazonaws.".$site."\n/onca/xml\n".implode("&",$sort_requestparams);
// $request = "GET\necs.amazonaws.com\n/onca/xml\n".$requestparams;

$request = str_replace(':','%3A',$request);
$request = str_replace(';','%3B',$request);
$request = str_replace(',','%2C',$request);

// Signing
$signature = base64_encode(hash_hmac("sha256",$request,$SECRET_ACCESS_KEY,TRUE));

$signature = str_replace('+','%2B',$signature);
$signature = str_replace('=','%3D',$signature);
$signature = str_replace('/','%2F',$signature);

$xmlUrl = 'http://ecs.amazonaws.'.$site.'/onca/xml?'.$requestparams.'&Signature='.$signature;

// echo '<a href="'.$xmlUrl.'" target="new">The Request</a>';


that last line i uncomment if i run into trouble. it then gives me the request link i have assembled that i can use to check the amazon (XML) document for details, either an error message or the document structure, which i may need in order to access the different XML elements.

to make things very easy i have made my version available for download.

and of course the scripts runs as a live demo.

i hope some users may find this useful. if there's any problems, just leave comments and we'll see how we can improve it further, if and when necessary.

enjoy!

tom.paine


Software: Unlocker

ever so often i came across this error message:

Cannot delete folder: It is being used by another person or program.

the other day i decided to search the internet for comments or a solution to this problem and ran across the website of

CEDRICK 'NITCH' COLLOMB

who wrote a nice little program named Unlocker.

it's free software and a very nice tool to have.

i installed it with the default settings given.

when i now come across a folder that cannot be deleted, after a moment this little tool opens a separate window asking what i would like to do: kill the process, or just release the folder, after which i can try to delete the folder again. so far it has always worked and it's very nice to have.

of course the software supports not only folders, but files as well. i usually had the problem when i moved a complete folder to another drive, and once the folder was empty it could not necessarily be deleted.

i hope that others my find this useful, too.

enjoy!

tom.paine