Playing with Amazon AWS
I have been playing a bit with Yahoo! Shoposphere which I posted about recently. I really like the concept, but sadly there is no revenue share yet and no way to attach my contact data to my shopping list. It’s also actually geared to putting things in there that are already in your hands, that you tested. But I wanted to look at using something like that in relation to AdSense.
AdSense allows you to add a default ad that would be shown instead of the public service announcements that come there if Google does not find anything to link to your site. But what to add? There are some services that tailor to this system but I always felt you would have to do something that is very personal to yourself. Enter Amazon’s Wishlist and the Amazon WebService, AWS in short.
There you can register and get your developer ID and actually build a nice REST query that will give you back your Wishlist. It currently only seems to do that for a US wishlist but who cares. I set one up and the query is easy to set up, especially with the help of AWS Zone.
Here is my query:
<http://xml-us.amznxslt.com/onca/xml?Service=AWSECommerceService>
&Version=2005-03-23
&Operation=ListLookup
&Style=http%3A%2F%2Fthylmann.net%2Fmy-wishlist%2Famazon.xslt
&ContentType=text%2Fhtml
&SubscriptionId=hidden
&ListId=UOV88WC3Q1WF
&ListType=WishList
&Condition=All
&DeliveryMethod=Ship
&ResponseGroup=Images%2CSmall
&Sort=LastUpdated
That gives me a lookup of a specific wishlist, returning text/html, including images and a description, ordered by last updated. It would be nice to be ordering by rating but that did not seem to be there.
You see one interesting item in there, which is _Style_. There another URL can be found:
_http://thylmann.net/my-wishlist/amazon.xslt_
This is a relatively simple XSLT file that turn the output I get into anything I want, server side, by AWS. Very handy indeed. These together already give me a small box in the standard size of an AdSense ad, configurable in design, with the 4 items I have in my Wishlist over there.
Next comes PHP, which mangles what comes out of there a bit, because what I really need is an output in kind of Javascript. One thing that is important is that the output HTML needs to be all in one line, without ‘ or it will not return anything.
? print "document.write('";
$string = fopen("the above url", "r");
// now I replace both linebreaks and '
while (!feof($string)) {
$buffer = fgets($string, 4096);
$say = ereg_replace("n","",$buffer);
$say2 = ereg_replace("'"," ",$say);
echo $say2;
}
fclose($string);
print "');";
?
What does that give me? It produces the following output, which I can theoretically add as my default AdSense ad, built from my Wishlist, configurable in CSS, and with the stuff automatically going to the right address if somebody chooses to send them around. :)
Comment: The Sigma Lense and Lowepro is already communicated to other people, so I am very sorry for my readers that they will only be able to give me the other two items if they are so inclined ;)
Technorati Tags: AdSense, Advertising, Amazon, AWS, XSLT

