The How and Why of Barcamp

We’re on our final approach to next month’s Barcamp Vancouver which is shaping up nicely due to the contributions of many volunteers and a list of wonderful sponsors. But one thing bothers me – any time I mention Barcamp to most people I get one of two perplexing responses:

  1. “What’s that?”
  2. “Why would I want to participate?”

This post is designed to answer these questions for people in Vancouver.

To answer the first question: Barcamp is an unconference – this means that the participants determine the content. If you head on over to the topics, you’ll see sessions that various people want to present and moderate during Barcamp. In fact, the first thing you’ll notice is that you probably don’t know a single speaker. There are no rockstar presenters, à la TED; Al Gore will not be dropping by prior to heading out to save the whales.

Instead, the speakers are ordinary people – just like you! They’ve got something they’ve built, started, been involved in, or are generally passionate about that they want to share with other people who might be interested. They bring something unique to the conference for people to explore, understand, and comment upon. That’s it.

Which brings us to the second question: why should you participate? Well, in a nutshell, because you can. Everyone has something they’re working on that they should share with other like-minded individuals. Sharing is scary, but sharing makes it real; sharing not only validates what you’re working on, but also gives you a great opportunity to tap into the passion and expertise of a whole community.

Back in 2005, I gave a talk on SVG v. AJAX (creatively titled “Ajax-Schmajax”) at the first Barcamp. In honesty, I almost didn’t present until Scott Beale (of Laughing Squid fame in San Francisco) prodded me into presenting over a cocktail at the pre-Barcamp party. When I pointed out that I wasn’t sure why anyone should care about my topic, his advice was simple: “It doesn’t matter what your topic is, all that matters is that you share it with the others and see where it leads. That’s how we do things in Silicon Valley.”

So yes, I was peer-pressured into presenting at an unconference. And now this is me pressuring you to present at Barcamp: get your session on the list of proposed topics (and not living in Vancouver is not a barrier – sign up for a remote session). Let’s make the Vancouver technology/maker/tinkerer community a “share by default” community.

Signing Amazon Web Service Requests in ActionScript announced a change to its Product Advertising API requiring all requests after August 15, 2009 to be signed. I’d been meaning to update one of the Scannerfly example applications and the Shelfari Scanner to sign Amazon requests, but was hoping someone else would figure it out before me. As near as I can tell, no one has provided an implementation in ActionScript, so I cobbled one together.

Generally, the process is fairly straighforward: developers need to transform their REST request’s parameters into a canonical form, add a timestamp, and then append a signed version of the resulting string. However, in reality there a lots of finicky details that make the process frustrating…luckily for you, I’ve created an ActionScript implementation that you should be able to modify to suit your purposes.

The signature process relies on the as3crypto library to provide HMAC and SHA-256 implementations. In addition, you’ll need an instance of mx.rpc.http.HttpService that you’ve likely instantiated in your MXML, along with your Amazon Web Services developer ID and secret key:

// A HTTPService configured to perform the required Amazon Web Services request.
<mx:HTTPService id="AmazonSearch" url="" showBusyCursor="true">
// The Amazon host providing the Product API web service.
private const AWS_HOST:String = "";
// The HTTP method used to send the request.
private const AWS_METHOD:String = "GET";
// The path to the Product API web service on the Amazon host.
private const AWS_PATH:String = "/onca/xml";
// The AWS Access Key ID to use when querying
private var amazonDeveloperId:String = "####################";
// The AWS Secret Key to use when querying
private var amazonSecretAccessKey:String = "####################";
// The request signature string.
private var signature:String;
// The request timestamp string, in UTC format (YYYY-MM-DDThh:mm:ssZ).
private var timestamp:String;
private function generateSignature():void
	var parameterArray:Array = new Array();
	var parameterCollection:ArrayCollection = new ArrayCollection();
	var parameterString:String = "";
	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.
	formatter.formatString = "YYYY-MM-DDTHH:NN:SS.000Z";
	now.setTime(now.getTime() + (now.getTimezoneOffset() * 60 * 1000));
	timestamp = formatter.format(now);
	// Process the parameters.
	for (var key:String in AmazonSearch.request )
		// Ignore the "Signature" request parameter.
		if (key != "Signature")
			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, "%20")));
			// Use the byte values, not the string values.
			parameterCollection.addItem( { parameter : parameterBytes , value : valueBytes } );
	// Sort the parameters and formulate the parameter string to be signed.
	parameterCollection.sort = sort;
	sort.fields = [ new SortField("parameter", true), new SortField("value", true) ];
	parameterString = AWS_METHOD + "\n" + AWS_HOST + "\n" + AWS_PATH + "\n";
	for (var i:Number = 0; i < parameterCollection.length; i++)
		var pair:Object = parameterCollection.getItemAt(i);
		parameterString += pair.parameter + "=" + pair.value;
		if (i < parameterCollection.length - 1)
			parameterString += "&";
	// Sign the parameter string to generate the request signature.
	hmacBytes = hmac.compute(keyBytes, requestBytes);
	signature = encodeURIComponent(encoder.toString());
// Somewhere in your code you'll call the following to generate request signature and perform the search.

And for those who need a complete working example, you can download the MXML for an example application from here. The example simply performs an ItemLookup; however, you will still need to add your Amazon developer ID and secret key for the example to work.

A note to other developers struggling with implementing the proper request signature, see the Signed Request Helper. This Javascript application breaks down each step in the formulating the normalized parameter string and signature.