<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Signing Amazon Web Service Requests in ActionScript</title>
	<atom:link href="http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/</link>
	<description>The personal web site of Brendon J. Wilson, a software developer, technologist, and entrepreneur living in Vancouver, British Columbia, Canada.</description>
	<lastBuildDate>Wed, 18 Jan 2012 10:11:14 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Anton</title>
		<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/comment-page-1/#comment-386875</link>
		<dc:creator>Anton</dc:creator>
		<pubDate>Fri, 20 May 2011 06:13:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.brendonwilson.com/?p=631#comment-386875</guid>
		<description>Hi Brandon,

please delete my first post;-)

your App is running fine even under Flex 4.

My Problem was that the &quot;Bugfix&quot; 
from
signature = encodeURI(encoder.toString());
to 
encodeURIComponent(encoder.toString());
doesn&#039;t work. 

Sorry, Mihai!

The Signature after using encodeURIComponent is to short.

Thanks again for your great work, Brandon!

Grettings from cologne/germany

Uwe</description>
		<content:encoded><![CDATA[<p>Hi Brandon,</p>
<p>please delete my first post;-)</p>
<p>your App is running fine even under Flex 4.</p>
<p>My Problem was that the &#8220;Bugfix&#8221;<br />
from<br />
signature = encodeURI(encoder.toString());<br />
to<br />
encodeURIComponent(encoder.toString());<br />
doesn&#8217;t work. </p>
<p>Sorry, Mihai!</p>
<p>The Signature after using encodeURIComponent is to short.</p>
<p>Thanks again for your great work, Brandon!</p>
<p>Grettings from cologne/germany</p>
<p>Uwe</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anton</title>
		<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/comment-page-1/#comment-386748</link>
		<dc:creator>Anton</dc:creator>
		<pubDate>Thu, 19 May 2011 21:50:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.brendonwilson.com/?p=631#comment-386748</guid>
		<description>Hi Brendon,
your &quot;signaturegenerator&quot; works perfect, but i have a problem with excuting the httpservice.

Triggering the Amazonsearch.send() returns the errormessage: &quot;HTTP request error&quot;

The only thing I have changed is &quot;upgrading&quot; your source from Flex 3 to Flex 4. It doesn&#039;t matter if i use &lt;mx:httpservice and &lt;mx:request or the spark equivalent. the error is the same.

The Signature-Part is working fine.

Bringing the elements with cut &amp; paste and a little modification together: &quot;http://&quot; + endpoint-url +&quot;?&quot; + request-values + &amp;Signature returns after copying the url and executing it in a browser the expected result. That is  great!!!!


Have I done something wrong when I make a flex 4 app out of your mxml-file? Changing &lt;mx:httpService and &lt;mx:request to spark makes no difference. 

Is something in my crossdomain.xml wrong and do I need this file for this httpservice-connection?




   
   



Her comes my less modified version of your example.

Look at the alert-boxes. All values are correct!




	
		
		
			
				{amazonDeveloperId}
				EAN
				9783934358058
				ItemLookup
				ItemAttributes,Images,Tracks,EditorialReview
				Books
				AWSECommerceService
				{signature}
				{timestamp}
			
		
		
	
	
		
			&lt;![CDATA[
			import com.hurlant.crypto.hash.HMAC;
			import com.hurlant.crypto.hash.SHA256;
			
			import mx.collections.ArrayCollection;
			import mx.collections.Sort;
			import mx.collections.SortField;
			import mx.controls.Alert;
			import mx.formatters.DateFormatter;
			import mx.rpc.events.ResultEvent;
			import mx.rpc.http.HTTPService;
			import mx.utils.Base64Encoder;
				
					
				
				/*
				//Changes: 
				
				url=&quot;http://ecs.amazonaws.de/onca/xml&quot;
				
				
				...
				
				
				url=&quot;http://webservices.amazon.com/onca/xml&quot;
				AWS_HOST:String = &quot;webservices.amazon.com&quot;;
				
				
				German Endpoint:
				url=&quot;http://ecs.amazonaws.de/onca/xml&quot;
				AWS_HOST:String = &quot;ecs.amazonaws.de&quot;;
				*/
				
				/*
				
				Ablauf der Signatur aus : http://associates-amazon.s3.amazonaws.com/signed-requests/helper/index.html
				Das folgende Beispiel wurde getestet. Es handelt sich um das Flash4 Buch von S. Wolter	
				String-To-Sign wird hier aus den Parametern aufgebaut:
				Hinweis: Die Signatur ist noch nicht enthalten, das sie nun aus diesen Werten erzeugt wird!
				GET
				ecs.amazonaws.de
				/onca/xml
				AWSAccessKeyId=***MYKEY***&amp;
				AssociateTag=mytag-20&amp;
				IdType=ISBN&amp;
				ItemId=3924322112&amp;
				Operation=ItemLookup&amp;
				ResponseGroup=ItemAttributes%2COffers%2CImages%2CReviews%2CVariations&amp;
				SearchIndex=Books&amp;
				Service=AWSECommerceService&amp;
				Sort=salesrank&amp;
				Timestamp=2011-05-19T13%3A17%3A27.000Z&amp;
				Version=2009-01-01
				
				
				daraus ergibt sich die Signed URL:
				
				http://ecs.amazonaws.de/onca/xml?
				AWSAccessKeyId=***MYKEY***&amp;
				AssociateTag=mytag-20&amp;
				IdType=ISBN&amp;
				ItemId=3924322112&amp;
				Operation=ItemLookup&amp;
				ResponseGroup=ItemAttributes%2COffers%2CImages%2CReviews%2CVariations&amp;
				SearchIndex=Books&amp;
				Service=AWSECommerceService&amp;
				Sort=salesrank&amp;
				Timestamp=2011-05-19T13%3A17%3A27.000Z&amp;
				Version=2009-01-01&amp;
				Signature=plM4oRhUyxSZumgQ7q7X6GsbGGWpvVjCch1eV5K%2B7ps%3D
				
				
				
				---------------------------------------------------------------
				
				mit diesem Programm wurde erzeugt:
				Hinweis die Parameter weichen etwas von den App-Parametern ab
				GET
				ecs.amazonaws.de
				/onca/xml
				AWSAccessKeyId=***MYKEY***&amp;
				IdType=EAN&amp;
				ItemId=9783934358058&amp;
				Operation=ItemLookup&amp;
				ResponseGroup=ItemAttributes%2CImages%2CTracks%2CEditorialReview&amp;
				SearchIndex=Books&amp;
				Service=AWSECommerceService&amp;
				Timestamp=2011-05-19T14%3A45%3A41.000Z
				
				
				Manuell zusammengestetzt funktioniert der REST-Request: 
				
				Es wurde &quot;http://&quot;, das &quot;?&quot; hinter xml und &quot;&amp;Signature=f5km6UtycJVjUsxfpFbxZfcWVaS0CmziR7tBATHdCJE%3D&quot; hinzugefuegt:
				Bitte beachten: Die Signatur wurde OHNE diese Ergaenzungen erzeugt !!!
				http://ecs.amazonaws.de/onca/xml?
				AWSAccessKeyId=***MYKEY***&amp;
				IdType=EAN&amp;ItemId=9783934358058&amp;
				Operation=ItemLookup&amp;
				ResponseGroup=ItemAttributes%2CImages%2CTracks%2CEditorialReview&amp;
				SearchIndex=Books&amp;
				Service=AWSECommerceService&amp;
				Timestamp=2011-05-19T14%3A58%3A15.000Z&amp;
				Signature=f5km6UtycJVjUsxfpFbxZfcWVaS0CmziR7tBATHdCJE%3D
				
				
				*/
				
				
			
			/**
			* The Amazon host providing the Product API web service.
			*/
			//private const AWS_HOST:String = &quot;ecs.amazonaws.de&quot;;
			private const AWS_HOST:String = &quot;webservices.amazon.com&quot;;
				
			/**
			* The HTTP method used to send the request.
			*/
			private const AWS_METHOD:String = &quot;GET&quot;;
			
			/**
			* The path to the Product API web service on the Amazon host.
			*/
			private const AWS_PATH:String = &quot;/onca/xml&quot;;
			
			/**
			* The AWS Access Key ID to use when querying Amazon.com.
			*/
			[Bindable]
			private var amazonDeveloperId:String = &quot;***MYKEY***&quot;;
			
			/**
			* The AWS Secret Key to use when querying Amazon.com.
			*/
			[Bindable]
			private var amazonSecretAccessKey:String = &quot;***MYSECRETKEY***&quot;;
			
			/**
			* The request signature string.
			*/
			[Bindable]
			private var signature:String;
			
			/**
			* The request timestamp string, in UTC format (YYYY-MM-DDThh:mm:ssZ).
			*/
			[Bindable]
			private var timestamp:String;
			
			
			/**
			* Calls all of the registered Javascript callback functions with
			* the details on the barcodes that have been detected.
			*/
			private function init():void
			{
			// Generate request signature and perform the search.
			generateSignature();

			//mx.controls.Alert.show(&quot;amazonDeveloperId:&quot; + amazonDeveloperId);
			mx.controls.Alert.show(&quot;&amp;signature=&quot; + signature);
			mx.controls.Alert.show(&quot;&amp;timestamp=&quot; +  timestamp);
			
			var req:String = &quot;&quot;;
			
			req += &quot;AWSAccessKeyId =&quot; + this.AmazonSearch.request.AWSAccessKeyId + &quot;\n&quot;;	
			req += &quot;IdType =&quot; + this.AmazonSearch.request.IdType+ &quot;\n&quot;;	
			req += &quot;ItemId =&quot; + this.AmazonSearch.request.ItemId+ &quot;\n&quot;;	
			req += &quot;Operation =&quot; + this.AmazonSearch.request.Operation+ &quot;\n&quot;;
			req += &quot;ResponseGroup =&quot; + this.AmazonSearch.request.ResponseGroup+ &quot;\n&quot;;
			req += &quot;SearchIndex =&quot; + this.AmazonSearch.request.SearchIndex+ &quot;\n&quot;;
			req += &quot;Service =&quot; + this.AmazonSearch.request.Service+ &quot;\n&quot;;
			req += &quot;Signature =&quot; + this.AmazonSearch.request.Signature+ &quot;\n&quot;;
			req += &quot;Timestamp =&quot; + this.AmazonSearch.request.Timestamp+ &quot;\n&quot;;
			
			Alert.show(&quot;requstValues:\n&quot; + req);
			
			}
			
			/**
			* Displays the dialog box with the details retrieved from Amazon.
			* This function is called by the AmazonSearch object&#039;s ItemLookup
			* operation. Note that scanning is paused while the dialog box
			* is being displayed.
			*
			* @param res The results of the query to Amazon.com.
			*/
			private function showItemLookupResults(res:ResultEvent):void
			{
				
			var details:Object = res.result.ItemLookupResponse.Items.Item;
			
			if (details != null)
			{
				// TODO: Do something with the result of the request.
				Alert.show(&quot;detailResults&quot; + details);
			}
			}
			
			/**
			* Handles generating the signature for the AWS request. See the
			* request authentication process details in the documentation for
			* Amazon&#039;s Product API, available at:
			* 
			* 		http://docs.amazonwebservices.com/AWSECommerceService/2009-07-01/DG/HMACSignatures.html
			* 
			* There are also examples of the necessary canonicalization at:
			* 
			* 		http://docs.amazonwebservices.com/AWSECommerceService/2009-07-01/DG/rest-signature.html
			* 
			* @return The base64-encoded Amazon request signature.
			*/
			private function generateSignature():void
			{
			var parameterArray:Array = new Array();
			var parameterCollection:ArrayCollection = new ArrayCollection();
			var parameterString:String = &quot;&quot;;
			var sort:Sort = new Sort();
			var hmac:HMAC = new HMAC(new SHA256());
			var requestBytes:ByteArray = new ByteArray();
			var keyBytes:ByteArray = new ByteArray();
			var hmacBytes:ByteArray;
			var encoder:Base64Encoder = new Base64Encoder();
			var formatter:DateFormatter = new DateFormatter();
			var now:Date = new Date();
			
			// Set the request timestamp using the format: YYYY-MM-DDThh:mm:ss.000Z
			// Note that we must convert to GMT.
			//Version vor dem Bugfix: 1-24
			//formatter.formatString = &quot;YYYY-MM-DDTHH:NN:SS.000Z&quot;;
			
			//BUGFIX: Amazon is expecting JJ for 0-23
			formatter.formatString = &quot;YYYY-MM-DDTJJ:NN:SS.000Z&quot;;
			
			now.setTime(now.getTime() + (now.getTimezoneOffset() * 60 * 1000));
			timestamp = formatter.format(now);
			
			// Process the parameters.
			for (var key:String in AmazonSearch.request )
			{
			// Ignore the &quot;Signature&quot; request parameter.
			if (key != &quot;Signature&quot;)
			{
			var urlEncodedKey:String = encodeURIComponent(decodeURIComponent(key));
			var parameterBytes:ByteArray = new ByteArray();
			var valueBytes:ByteArray = new ByteArray();
			var value:String = AmazonSearch.request[key];
			var urlEncodedValue:String = encodeURIComponent(decodeURIComponent(value.replace(/\+/g, &quot;%20&quot;)));
			
			// Use the byte values, not the string values.
			parameterBytes.writeUTFBytes(urlEncodedKey);
			valueBytes.writeUTFBytes(urlEncodedValue);
			parameterCollection.addItem( { parameter : parameterBytes , value : valueBytes } );
			}
			}
			
			// Sort the parameters and formulate the parameter string to be signed.
			parameterCollection.sort = sort;
			sort.fields = [ new SortField(&quot;parameter&quot;, true), new SortField(&quot;value&quot;, true) ];
			parameterCollection.refresh();
			parameterString = AWS_METHOD + &quot;\n&quot; + AWS_HOST + &quot;\n&quot; + AWS_PATH + &quot;\n&quot;;
			for (var i:Number = 0; i &lt; parameterCollection.length; i++)
			{
			var pair:Object = parameterCollection.getItemAt(i);
			
			
			parameterString += pair.parameter + &quot;=&quot; + pair.value;
			
			if (i 
		
	
	
	
</description>
		<content:encoded><![CDATA[<p>Hi Brendon,<br />
your &#8220;signaturegenerator&#8221; works perfect, but i have a problem with excuting the httpservice.</p>
<p>Triggering the Amazonsearch.send() returns the errormessage: &#8220;HTTP request error&#8221;</p>
<p>The only thing I have changed is &#8220;upgrading&#8221; your source from Flex 3 to Flex 4. It doesn&#8217;t matter if i use &lt;mx:httpservice and &lt;mx:request or the spark equivalent. the error is the same.</p>
<p>The Signature-Part is working fine.</p>
<p>Bringing the elements with cut &amp; paste and a little modification together: &quot;<a href="http://&#038;quot" rel="nofollow">http://&#038;quot</a>; + endpoint-url +&quot;?&quot; + request-values + &amp;Signature returns after copying the url and executing it in a browser the expected result. That is  great!!!!</p>
<p>Have I done something wrong when I make a flex 4 app out of your mxml-file? Changing &lt;mx:httpService and &lt;mx:request to spark makes no difference. </p>
<p>Is something in my crossdomain.xml wrong and do I need this file for this httpservice-connection?</p>
<p>Her comes my less modified version of your example.</p>
<p>Look at the alert-boxes. All values are correct!</p>
<p>				{amazonDeveloperId}<br />
				EAN<br />
				9783934358058<br />
				ItemLookup<br />
				ItemAttributes,Images,Tracks,EditorialReview<br />
				Books<br />
				AWSECommerceService<br />
				{signature}<br />
				{timestamp}</p>
<p>			&lt;![CDATA[<br />
			import com.hurlant.crypto.hash.HMAC;<br />
			import com.hurlant.crypto.hash.SHA256;</p>
<p>			import mx.collections.ArrayCollection;<br />
			import mx.collections.Sort;<br />
			import mx.collections.SortField;<br />
			import mx.controls.Alert;<br />
			import mx.formatters.DateFormatter;<br />
			import mx.rpc.events.ResultEvent;<br />
			import mx.rpc.http.HTTPService;<br />
			import mx.utils.Base64Encoder;</p>
<p>				/*<br />
				//Changes: </p>
<p>				url=&quot;<a href="http://ecs.amazonaws.de/onca/xml&#038;quot" rel="nofollow">http://ecs.amazonaws.de/onca/xml&#038;quot</a>;</p>
<p>				...</p>
<p>				url="http://webservices.amazon.com/onca/xml"<br />
				AWS_HOST:String = "webservices.amazon.com";</p>
<p>				German Endpoint:<br />
				url="http://ecs.amazonaws.de/onca/xml"<br />
				AWS_HOST:String = "ecs.amazonaws.de";<br />
				*/</p>
<p>				/*</p>
<p>				Ablauf der Signatur aus : <a href="http://associates-amazon.s3.amazonaws.com/signed-requests/helper/index.html" rel="nofollow">http://associates-amazon.s3.amazonaws.com/signed-requests/helper/index.html</a><br />
				Das folgende Beispiel wurde getestet. Es handelt sich um das Flash4 Buch von S. Wolter<br />
				String-To-Sign wird hier aus den Parametern aufgebaut:<br />
				Hinweis: Die Signatur ist noch nicht enthalten, das sie nun aus diesen Werten erzeugt wird!<br />
				GET<br />
				ecs.amazonaws.de<br />
				/onca/xml<br />
				AWSAccessKeyId=***MYKEY***&amp;<br />
				AssociateTag=mytag-20&amp;<br />
				IdType=ISBN&amp;<br />
				ItemId=3924322112&amp;<br />
				Operation=ItemLookup&amp;<br />
				ResponseGroup=ItemAttributes%2COffers%2CImages%2CReviews%2CVariations&amp;<br />
				SearchIndex=Books&amp;<br />
				Service=AWSECommerceService&amp;<br />
				Sort=salesrank&amp;<br />
				Timestamp=2011-05-19T13%3A17%3A27.000Z&amp;<br />
				Version=2009-01-01</p>
<p>				daraus ergibt sich die Signed URL:</p>
<p>				<a href="http://ecs.amazonaws.de/onca/xml?" rel="nofollow">http://ecs.amazonaws.de/onca/xml?</a><br />
				AWSAccessKeyId=***MYKEY***&amp;<br />
				AssociateTag=mytag-20&amp;<br />
				IdType=ISBN&amp;<br />
				ItemId=3924322112&amp;<br />
				Operation=ItemLookup&amp;<br />
				ResponseGroup=ItemAttributes%2COffers%2CImages%2CReviews%2CVariations&amp;<br />
				SearchIndex=Books&amp;<br />
				Service=AWSECommerceService&amp;<br />
				Sort=salesrank&amp;<br />
				Timestamp=2011-05-19T13%3A17%3A27.000Z&amp;<br />
				Version=2009-01-01&amp;<br />
				Signature=plM4oRhUyxSZumgQ7q7X6GsbGGWpvVjCch1eV5K%2B7ps%3D</p>
<p>				---------------------------------------------------------------</p>
<p>				mit diesem Programm wurde erzeugt:<br />
				Hinweis die Parameter weichen etwas von den App-Parametern ab<br />
				GET<br />
				ecs.amazonaws.de<br />
				/onca/xml<br />
				AWSAccessKeyId=***MYKEY***&amp;<br />
				IdType=EAN&amp;<br />
				ItemId=9783934358058&amp;<br />
				Operation=ItemLookup&amp;<br />
				ResponseGroup=ItemAttributes%2CImages%2CTracks%2CEditorialReview&amp;<br />
				SearchIndex=Books&amp;<br />
				Service=AWSECommerceService&amp;<br />
				Timestamp=2011-05-19T14%3A45%3A41.000Z</p>
<p>				Manuell zusammengestetzt funktioniert der REST-Request: </p>
<p>				Es wurde "http://", das "?" hinter xml und "&amp;Signature=f5km6UtycJVjUsxfpFbxZfcWVaS0CmziR7tBATHdCJE%3D" hinzugefuegt:<br />
				Bitte beachten: Die Signatur wurde OHNE diese Ergaenzungen erzeugt !!!<br />
				<a href="http://ecs.amazonaws.de/onca/xml?" rel="nofollow">http://ecs.amazonaws.de/onca/xml?</a><br />
				AWSAccessKeyId=***MYKEY***&amp;<br />
				IdType=EAN&amp;ItemId=9783934358058&amp;<br />
				Operation=ItemLookup&amp;<br />
				ResponseGroup=ItemAttributes%2CImages%2CTracks%2CEditorialReview&amp;<br />
				SearchIndex=Books&amp;<br />
				Service=AWSECommerceService&amp;<br />
				Timestamp=2011-05-19T14%3A58%3A15.000Z&amp;<br />
				Signature=f5km6UtycJVjUsxfpFbxZfcWVaS0CmziR7tBATHdCJE%3D</p>
<p>				*/</p>
<p>			/**<br />
			* The Amazon host providing the Product API web service.<br />
			*/<br />
			//private const AWS_HOST:String = "ecs.amazonaws.de";<br />
			private const AWS_HOST:String = "webservices.amazon.com";</p>
<p>			/**<br />
			* The HTTP method used to send the request.<br />
			*/<br />
			private const AWS_METHOD:String = "GET";</p>
<p>			/**<br />
			* The path to the Product API web service on the Amazon host.<br />
			*/<br />
			private const AWS_PATH:String = "/onca/xml";</p>
<p>			/**<br />
			* The AWS Access Key ID to use when querying Amazon.com.<br />
			*/<br />
			[Bindable]<br />
			private var amazonDeveloperId:String = &#8220;***MYKEY***&#8221;;</p>
<p>			/**<br />
			* The AWS Secret Key to use when querying Amazon.com.<br />
			*/<br />
			[Bindable]<br />
			private var amazonSecretAccessKey:String = &#8220;***MYSECRETKEY***&#8221;;</p>
<p>			/**<br />
			* The request signature string.<br />
			*/<br />
			[Bindable]<br />
			private var signature:String;</p>
<p>			/**<br />
			* The request timestamp string, in UTC format (YYYY-MM-DDThh:mm:ssZ).<br />
			*/<br />
			[Bindable]<br />
			private var timestamp:String;</p>
<p>			/**<br />
			* Calls all of the registered Javascript callback functions with<br />
			* the details on the barcodes that have been detected.<br />
			*/<br />
			private function init():void<br />
			{<br />
			// Generate request signature and perform the search.<br />
			generateSignature();</p>
<p>			//mx.controls.Alert.show(&#8220;amazonDeveloperId:&#8221; + amazonDeveloperId);<br />
			mx.controls.Alert.show(&#8220;&amp;signature=&#8221; + signature);<br />
			mx.controls.Alert.show(&#8220;&amp;timestamp=&#8221; +  timestamp);</p>
<p>			var req:String = &#8220;&#8221;;</p>
<p>			req += &#8220;AWSAccessKeyId =&#8221; + this.AmazonSearch.request.AWSAccessKeyId + &#8220;\n&#8221;;<br />
			req += &#8220;IdType =&#8221; + this.AmazonSearch.request.IdType+ &#8220;\n&#8221;;<br />
			req += &#8220;ItemId =&#8221; + this.AmazonSearch.request.ItemId+ &#8220;\n&#8221;;<br />
			req += &#8220;Operation =&#8221; + this.AmazonSearch.request.Operation+ &#8220;\n&#8221;;<br />
			req += &#8220;ResponseGroup =&#8221; + this.AmazonSearch.request.ResponseGroup+ &#8220;\n&#8221;;<br />
			req += &#8220;SearchIndex =&#8221; + this.AmazonSearch.request.SearchIndex+ &#8220;\n&#8221;;<br />
			req += &#8220;Service =&#8221; + this.AmazonSearch.request.Service+ &#8220;\n&#8221;;<br />
			req += &#8220;Signature =&#8221; + this.AmazonSearch.request.Signature+ &#8220;\n&#8221;;<br />
			req += &#8220;Timestamp =&#8221; + this.AmazonSearch.request.Timestamp+ &#8220;\n&#8221;;</p>
<p>			Alert.show(&#8220;requstValues:\n&#8221; + req);</p>
<p>			}</p>
<p>			/**<br />
			* Displays the dialog box with the details retrieved from Amazon.<br />
			* This function is called by the AmazonSearch object&#8217;s ItemLookup<br />
			* operation. Note that scanning is paused while the dialog box<br />
			* is being displayed.<br />
			*<br />
			* @param res The results of the query to Amazon.com.<br />
			*/<br />
			private function showItemLookupResults(res:ResultEvent):void<br />
			{</p>
<p>			var details:Object = res.result.ItemLookupResponse.Items.Item;</p>
<p>			if (details != null)<br />
			{<br />
				// TODO: Do something with the result of the request.<br />
				Alert.show(&#8220;detailResults&#8221; + details);<br />
			}<br />
			}</p>
<p>			/**<br />
			* Handles generating the signature for the AWS request. See the<br />
			* request authentication process details in the documentation for<br />
			* Amazon&#8217;s Product API, available at:<br />
			*<br />
			* 		<a href="http://docs.amazonwebservices.com/AWSECommerceService/2009-07-01/DG/HMACSignatures.html" rel="nofollow">http://docs.amazonwebservices.com/AWSECommerceService/2009-07-01/DG/HMACSignatures.html</a><br />
			*<br />
			* There are also examples of the necessary canonicalization at:<br />
			*<br />
			* 		<a href="http://docs.amazonwebservices.com/AWSECommerceService/2009-07-01/DG/rest-signature.html" rel="nofollow">http://docs.amazonwebservices.com/AWSECommerceService/2009-07-01/DG/rest-signature.html</a><br />
			*<br />
			* @return The base64-encoded Amazon request signature.<br />
			*/<br />
			private function generateSignature():void<br />
			{<br />
			var parameterArray:Array = new Array();<br />
			var parameterCollection:ArrayCollection = new ArrayCollection();<br />
			var parameterString:String = &#8220;&#8221;;<br />
			var sort:Sort = new Sort();<br />
			var hmac:HMAC = new HMAC(new SHA256());<br />
			var requestBytes:ByteArray = new ByteArray();<br />
			var keyBytes:ByteArray = new ByteArray();<br />
			var hmacBytes:ByteArray;<br />
			var encoder:Base64Encoder = new Base64Encoder();<br />
			var formatter:DateFormatter = new DateFormatter();<br />
			var now:Date = new Date();</p>
<p>			// Set the request timestamp using the format: YYYY-MM-DDThh:mm:ss.000Z<br />
			// Note that we must convert to GMT.<br />
			//Version vor dem Bugfix: 1-24<br />
			//formatter.formatString = &#8220;YYYY-MM-DDTHH:NN:SS.000Z&#8221;;</p>
<p>			//BUGFIX: Amazon is expecting JJ for 0-23<br />
			formatter.formatString = &#8220;YYYY-MM-DDTJJ:NN:SS.000Z&#8221;;</p>
<p>			now.setTime(now.getTime() + (now.getTimezoneOffset() * 60 * 1000));<br />
			timestamp = formatter.format(now);</p>
<p>			// Process the parameters.<br />
			for (var key:String in AmazonSearch.request )<br />
			{<br />
			// Ignore the &#8220;Signature&#8221; request parameter.<br />
			if (key != &#8220;Signature&#8221;)<br />
			{<br />
			var urlEncodedKey:String = encodeURIComponent(decodeURIComponent(key));<br />
			var parameterBytes:ByteArray = new ByteArray();<br />
			var valueBytes:ByteArray = new ByteArray();<br />
			var value:String = AmazonSearch.request[key];<br />
			var urlEncodedValue:String = encodeURIComponent(decodeURIComponent(value.replace(/\+/g, &#8220;%20&#8243;)));</p>
<p>			// Use the byte values, not the string values.<br />
			parameterBytes.writeUTFBytes(urlEncodedKey);<br />
			valueBytes.writeUTFBytes(urlEncodedValue);<br />
			parameterCollection.addItem( { parameter : parameterBytes , value : valueBytes } );<br />
			}<br />
			}</p>
<p>			// Sort the parameters and formulate the parameter string to be signed.<br />
			parameterCollection.sort = sort;<br />
			sort.fields = [ new SortField("parameter", true), new SortField("value", true) ];<br />
			parameterCollection.refresh();<br />
			parameterString = AWS_METHOD + &#8220;\n&#8221; + AWS_HOST + &#8220;\n&#8221; + AWS_PATH + &#8220;\n&#8221;;<br />
			for (var i:Number = 0; i &lt; parameterCollection.length; i++)<br />
			{<br />
			var pair:Object = parameterCollection.getItemAt(i);</p>
<p>			parameterString += pair.parameter + &quot;=&quot; + pair.value;</p>
<p>			if (i</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/comment-page-1/#comment-321950</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Thu, 07 Oct 2010 13:08:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.brendonwilson.com/?p=631#comment-321950</guid>
		<description>Hi Brendon,

Someone brought to my attention a bug in the code above.  There is 1 hour everyday when the script stops working and Amazon returns an &quot;invalid date&quot; error.  It is UTC 24.  The data format string uses the HH code for 1-24 while Amazon is expecting JJ for 0-23.

Fixed string:
formatter.formatString = &quot;YYYY-MM-DDTJJ:NN:SS.000Z&quot;;

--jason</description>
		<content:encoded><![CDATA[<p>Hi Brendon,</p>
<p>Someone brought to my attention a bug in the code above.  There is 1 hour everyday when the script stops working and Amazon returns an &#8220;invalid date&#8221; error.  It is UTC 24.  The data format string uses the HH code for 1-24 while Amazon is expecting JJ for 0-23.</p>
<p>Fixed string:<br />
formatter.formatString = &#8220;YYYY-MM-DDTJJ:NN:SS.000Z&#8221;;</p>
<p>&#8211;jason</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brendon J. Wilson</title>
		<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/comment-page-1/#comment-313167</link>
		<dc:creator>Brendon J. Wilson</dc:creator>
		<pubDate>Sat, 28 Aug 2010 16:41:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.brendonwilson.com/?p=631#comment-313167</guid>
		<description>Kirsten - the code is here for you to use as you see fit. Go crazy. 

I&#039;ll post another version with a license bundle (probably MIT or BSD license) when I get the chance.</description>
		<content:encoded><![CDATA[<p>Kirsten &#8211; the code is here for you to use as you see fit. Go crazy. </p>
<p>I&#8217;ll post another version with a license bundle (probably MIT or BSD license) when I get the chance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kirsten</title>
		<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/comment-page-1/#comment-311589</link>
		<dc:creator>Kirsten</dc:creator>
		<pubDate>Thu, 19 Aug 2010 14:17:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.brendonwilson.com/?p=631#comment-311589</guid>
		<description>Are there licensing issues around use of your example code? We plan to use it in another example (reference) application. Please advise... and thanks for posting the code, it works!</description>
		<content:encoded><![CDATA[<p>Are there licensing issues around use of your example code? We plan to use it in another example (reference) application. Please advise&#8230; and thanks for posting the code, it works!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/comment-page-1/#comment-310520</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Fri, 13 Aug 2010 16:37:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.brendonwilson.com/?p=631#comment-310520</guid>
		<description>Thanks a bunch for posting this code.  It still works :).</description>
		<content:encoded><![CDATA[<p>Thanks a bunch for posting this code.  It still works <img src='http://www.brendonwilson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cat H1N1 &#187; Blog Archive &#187; Three ways to sign URLs for Amazon Web Services</title>
		<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/comment-page-1/#comment-308908</link>
		<dc:creator>Cat H1N1 &#187; Blog Archive &#187; Three ways to sign URLs for Amazon Web Services</dc:creator>
		<pubDate>Wed, 04 Aug 2010 20:00:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.brendonwilson.com/?p=631#comment-308908</guid>
		<description>[...] Flex/Flash/AIR apps: You can use the ActionScript code here: Signing Amazon Web Service Requests in ActionScript [...]</description>
		<content:encoded><![CDATA[<p>[...] Flex/Flash/AIR apps: You can use the ActionScript code here: Signing Amazon Web Service Requests in ActionScript [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/comment-page-1/#comment-249610</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Wed, 02 Sep 2009 16:55:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.brendonwilson.com/?p=631#comment-249610</guid>
		<description>Yep right, I cannot understand why Amazon decided to add this fu*** security feature! Now the web service to get albums art is (alsmot) more secure than a paypall service ;-)</description>
		<content:encoded><![CDATA[<p>Yep right, I cannot understand why Amazon decided to add this fu*** security feature! Now the web service to get albums art is (alsmot) more secure than a paypall service <img src='http://www.brendonwilson.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brendon J. Wilson</title>
		<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/comment-page-1/#comment-249594</link>
		<dc:creator>Brendon J. Wilson</dc:creator>
		<pubDate>Wed, 02 Sep 2009 15:00:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.brendonwilson.com/?p=631#comment-249594</guid>
		<description>Tom - The problem probably isn&#039;t your use of corelib. Amazon is pretty particular about the encoding of the data (see the use of encodeURIComponent in the code above), so I would guess that was the source of your problem.</description>
		<content:encoded><![CDATA[<p>Tom &#8211; The problem probably isn&#8217;t your use of corelib. Amazon is pretty particular about the encoding of the data (see the use of encodeURIComponent in the code above), so I would guess that was the source of your problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.brendonwilson.com/blog/2009/07/31/signing-amazon-web-service-requests-in-actionscript/comment-page-1/#comment-249579</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Wed, 02 Sep 2009 13:32:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.brendonwilson.com/?p=631#comment-249579</guid>
		<description>Thanks you very much from France!

I tried using the corelib:

trace (HMAC.hash(key,data,SHA256));

But it doesnt work ;-(</description>
		<content:encoded><![CDATA[<p>Thanks you very much from France!</p>
<p>I tried using the corelib:</p>
<p>trace (HMAC.hash(key,data,SHA256));</p>
<p>But it doesnt work ;-(</p>
]]></content:encoded>
	</item>
</channel>
</rss>

