Sam StevensSam Stevens is a web developer and search marketer who runs Stevens Media from headquarters on Denman Island, BC, Canada.

Downloads

Subscribe to the RSS Feed »

Follow me on Twitter »



Find Programming Jobs

PHP Anaconda: Amazon AWS 4.0 Keyword Search Script

If you're looking for a quick and simple implementation of the Amazon Associates Web Service for your website, stick around and learn about how PHP Anaconda came to be.

On a number of my websites, I was using the old Amazon ECS web service to pull in a handful a related products based on a keyword search. I used a hacked up version of the Filzhut.de amazon_functions scripts. When March 31st of this year rolled around however, Amazon shut down the ECS service in favor the newer Associates Web Service (AWS). This was no surprise: Amazon AWS 4.0 was released back in mid-2005 (if memory serves me correctly), though it was a little buggy at first. Flash forward to 2008 and it was clear that I would have to come up with a new way to display Amazon products on my websites.

My needs were straightforward:

  • As simple as possible: not too many files, called with a simple include statement
  • Support for both PHP 4 and PHP 5
  • No dependencies on PEAR packages
  • Keyword search driven
  • Random results
  • Caching

I assumed it would be easy enough to hit up Google and find a prefab PHP microapp out there that would do the trick. Unfortunately, most of the stuff I found was not compatible with AWS 4.0 or was PHP 5 only. 

No worries, I thought, I'll just put Paul Reinheimer's Professional Web APIs with PHP book to good use. Using his scripts and guidance, I pasted together some code that would satisfy my needs, tested it out, and started to deploy it. Then on March 31, I noticed none of it was working! As it turns out, the code in Paul's book, published in July 2006—after Amazon AWS 4.0 had been released—was not AWS 4.0 compatible! After some forehead slapping, I leafed through the book and noticed that it didn't say anywhere what version of Amazon's web service the code was compatible with. Given Amazon's multiple offerings, that seemed like an oversight. I visited Paul's website, the Wrox forums, the author's notes on Amazon.com, but nowhere was there any mention of AWS 4.0-compatible code available. It was starting to look like I'd have to put a little more elbow grease into this.

I'm not one to reinvent the wheel though, so I hit up my bookshelf again and grabbed some code from Brett O'Connor's del.icio.us Mashups that would handle making the REST request to Amazon and process the results using the Snoopy library. Next, I pasted in Simon Willison's simple Instant Caching with PHP code for the caching mechanism. I was still having trouble making sense of the very deeply nested arrays in Amazon's response however, despite this using this handy function to make the output more manageable. In the end, I got some help from Christian Kamau, who created the code to output those tricky arrays into clean lists and randomize the output.

The result is PHP Anaconda, a simple Amazon AWS keyword search script that accesses the web service via REST and returns either three random results or the first ten results. There's nothing mind blowing here, it just does the job I needed it to, and since I'm sure I'm not the only one who wants this functionality, I've made it available for download:

There's a lot you can do with this code if you're willing to dig a little deeper. For those adventures I recommend the Amazon AWS Developer Guide. Have fun navigating the Rio Amazon, and watch out for piranhas. 

Share this: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Sphinn
  • StumbleUpon
  • TwitThis
  • del.icio.us
  • bodytext
  • Technorati
  • Pownce
  • description

Get help with WordPress and French locale dates and times

Have you ever had to develop a WordPress-powered website in a language other than English?

WordPress has the capability to serve your pages in the language of your choice. The WordPress community has already translated it into many languages, and there are themes, translation files, and support also available in many other languages.

With a client project I'm just about to roll out, I had to present all the content in Canadian French but keep the administrative interface in English. The translation tasks mostly fell into the realms of content, interface and layout graphics, making it a fairly smooth process. However, I did come across one small hiccup regarding post meta data dates and times, and wanted to document and share the solutions here.

In particular, I needed to translate this meta data:

This entry was posted on Tuesday, June 17th, 2008 at 5:37 pm and is filed under [category].

into French:

Cette entrée a été inscrite le mardi, 17 juin 2008 à 17 h 37 et elle est classée sous [category].

It's simple enough to translate text in single.php, but what about the date and time which are generated using the WordPress function, the_time()?

First, the file wp-includes/locale.php needs to be translated to include the French names of the days of the week and months. Using the FR .po file available from the WordPress Subversion repository, I edited the locale file. This can be downloaded here, and is intended to be used with WordPress version 2.0.0.11.

Next, you'll need to edit the two instances of the time function in single.php:

<?php the_time('l, j F, Y') ?>

<?php the_time('G \h i') ?>

Along with the translated text, you should now have this in your single.php template:

Cette entr&eacute;e a &eacute;t&eacute; inscrite le <?php the_time('l, j F, Y') ?> &agrave; <?php the_time('G \h i') ?> et elle est class&eacute;e sous <?php the_category(', ') ?>.

And there you have it!

Share this: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Sphinn
  • StumbleUpon
  • TwitThis
  • del.icio.us
  • bodytext
  • Technorati
  • Pownce
  • description

You'll need to pay to get out of ymail's pen

As of noon Pacific yesterday, Yahoo! is offering new email accounts on the ymail.com and rocketmail.com domains in an effort to "attract Web surfers unhappy with their current addresses."

I missed the launch by an hour, but still managed to grab a few accounts for my name and business name, such as samstevens@ and stevensmedia@. My plan was to simply forward these for now to my Gmail accounts.

Imagine my surprise when I couldn't find the email forwarding option! I did end up finding it, under the Mail Plus features.That's right, to simply forward a @ymail.com address, Yahoo! requires me to pay $19.95/year. Who are they kidding?

Combine this with no IMAP access and an extremely cluttered web mail interface, and all we have here is a money grab attempt with no strong value proposition.

I want Yahoo! to survive as an independent company, I really do, but they're going to have to get a helluva lot craftier than this if they want to swim in the same pond as Google and Microsoft.

Share this: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Sphinn
  • StumbleUpon
  • TwitThis
  • del.icio.us
  • bodytext
  • Technorati
  • Pownce
  • description

Did you help Mozilla set a world record today?

Download Day Firefox 3 Download Day launched this morning with the Mozilla community trying to set a Guinness World Record for the most software downloaded in 24 hrs. Were you a part of it?

If you'd like to show your Firefox colors, download this nice wallpaper created by motionblur to honor the release of Firefox 3.

I upgraded to Firefox 3 this evening on my main workstation. I read about the new features, then set about upgrading my extensions.

I would love to find a way to do a simple list export of all my extensions. I've found a couple of add-ons that will export the extensions, but all I want is a simple list that includes the extension name and version. Any tips?

These extensions upgraded automatically:

  • ColorZilla 1.9
  • Digg Firefox Extension 0.6.2
  • Greasemonkey 0.8.20080609.0
  • IE View 1.3.7
  • Image Zoom 0.3.1
  • Link Diagnosis 1.2.1
  • Live HTTP Headers 0.14
  • Mahalo Share 1.3.12
  • OperaView 0.6.1
  • PDF Download 1.0.1.2
  • Pearl Crescent Page Saver Basic 1.7.1
  • Popup ALT Attribute 1.3.2008052801
  • Print/Print Preview 0.6
  • RankChecker 1.3.2
  • Screen grab! 0.95
  • Search Button 0.5.2
  • SearchStatus 1.25
  • SEO For Firefox 2.7.1
  • StumbleUpon 3.18
  • Tamper Data 10.0.4
  • TwitterFox 1.5.5.4
  • Web Developer 1.1.6

I replaced these extensions with new versions or better extensions found at the Firefox Add-ons site:

  • del.icio.us 1.2 => Delicious Bookmarks 2.0.58
  • LoremIpsum Content Generator 0.4.3
  • Smart Digg Button => Digg for Firefox 0.6.2
  • Word Count 0.4 => Word Count Plus 1.2.1

This extension was upgraded by finding a hacked version at a user's website:

  • FEBE 5.3.1

This one was manually upgraded by editing the version number in the file, "\Profile\extensions\pasteandgo2@holio.lin\install.rdf":

  • Paste and Go 2 0.8

These are the extensions that I still need upgrades for to work with Firefox 3. The ones marked with an asterisk are those I consider "essentials":

  • Bookmark Duplicate Detector 0.6.4
  • Enhanced Bookmark Search 0.1.04.1
  • * Copy Plain Text 0.3.3
  • SEOpen 0.8
  • * TinyURL Creator 1.0.4
  • MetaTags 2.3.5.2

Firefox 3 is running smoothly thus far save for one issue that needs a fix: In previous versions of Firefox, I could type a search query into the search bar then hit Enter to run the search. In Firefox 3, hitting Enter doesn't initiate a search from the search bar. Instead, I have to use my mouse to click the magnifying glass icon in the search bar. I found the "searchbutton.enter_key" setting in about:config but I am unsure what the new value should be and if this is even the right setting to edit to re-enable the Enter-to-search functionality. I didn't turn anything helpful up browsing the mozillazine.org forums. Perhaps I'll just shut down for the night and find my problem gone at reboot tomorrow morning? Fingers crossed!

UPDATE: My problem with Enter-to-search didn't go away. My manual edit of the Paste and Go extension didn't work either. As a temporary measure, I've applied this hack to allow Firefox to use "incompatible" extensions. I just couldn't live without Paste and Go, Copy as Plain Text and TinyURL creator!

UPDATE 2: Enter-to-search is resolved! In about:config, change the value of searchbutton.compat_mode to true. Restart Firefox.

Share this: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Sphinn
  • StumbleUpon
  • TwitThis
  • del.icio.us
  • bodytext
  • Technorati
  • Pownce
  • description

tweeternet: An introduction to Twitter

Need to explain Twitter to a client, colleague, or friend?

tweeternet is a one page Twitter primer that I just put online in an effort to streamline my own efforts at describing the social networking and microblogging service.

I've linked to several blog posts about Twitter that I feel are best-of-breed. If you think I've missed one, just tweet me. Similarly, I'm pulling in my del.icio.us links tagged with "twitter" to provide a small directory of Twitter tools, applications and resources. If you'd like to suggest an addition to this, add me to your del.icio.us network and share the link.

Share this: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Sphinn
  • StumbleUpon
  • TwitThis
  • del.icio.us
  • bodytext
  • Technorati
  • Pownce
  • description

Twitter noise threatens tool's usefulness

I started using Twitter a couple of months ago after hearing a number of speakers praise the service at the Web Directions North conference in Vancouver.

My first impression was: "So what?" [cue: Miles Davis] Do I really care what other people are doing every minute of their day? No, I don't.

However, it wasn't long before I started to see the value of the 140 character info share commonly called a "tweet." There are plenty of useful tips and pointers I get throughout the day from the people I'm following.

I also see ways that businesses can benefit from using Twitter internally. The informal format of the tweet enables quick, collaborative sharing between co-workers and work groups, and provides relief from email and IM fatigue.

Certainly, the meteoric rise of Twitter is backed by true usefulness, and even the service's continual problems with scaling don't seem to be problematic enough to rock the boat in any serious way. (In fact, the scaling problem might actually be creating traffic-spiking buzz for Twitter.)

I do see a significant problem with Twitter though, and it's on the rise and difficult to control. That issue is "Twitter noise."

While I appreciate learning about twitizens' latest blog posts, their unique solutions to daily problems, and the links and resources they're generously sharing, I really don't want to know what you're eating, when you're sleeping, and what tickles your funny bone. Simply put, tweeting this kind of stuff is a waste of everyone's time, and I'd like to see "professional tweeters" put an end to all the "Good night!" and "I love sushi!" tweets once and for all. The "twitterverse" is growing exponentially and the more we can curb the small talk, the better the quality of the signal to noise ratio will be, ensuring a viable service for more than just a financial quarter or two. Failure to "cut the fat" will result in a stale and stunted has-been, with users bailing out in favor of the next great collaborative web app.

Twitter filtering and threading functionality would be helpful with keeping conversations tightly themed and easier to follow, but ultimately the quality of Twitter will depend on its users and whether or not we have enough self-control to filter out the noise we create–before we tweet it.

Share this: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Sphinn
  • StumbleUpon
  • TwitThis
  • del.icio.us
  • bodytext
  • Technorati
  • Pownce
  • description