Yearly Archives: 2010

Building iTunes Links

Have you ever wanted to link to an iTunes page? It’s easy enough to copy a long, nasty-looking URL like http://itunes.apple.com/us/album/yours-truly/id310905907 right from the application by right-clicking on the album art or title. This works well enough if you’re manually linking to an album or iPhone app from a blog post, but what if you need something a bit more user friendly?

It’s not documented terribly well, but you can create much nicer short “search” links using the itunes.com domain. Here are a few examples:

You can even combine the search links with your iTunes affiliate ID, if you know how to do it right. It looks something like this:

http://itunes.com/artist/album?partnerId=30&siteID=YOUR_AFFILIATE_ID

Now for the fun part… Wouldn’t it be neat to be able to generate the links automatically? I’m doing that over at Folk Music Site (a fun project I put together last summer, as I thought it would be neat to have a directory of noteworthy folk musicians). Here is some simple PHP that will generate iTunes links on-the-fly:

function get_itunes_link($artist, $album) {
 $affiliate_id = ''; //Linkshare affiliate ID for iTunes
 $artist = clean_itunes_string($artist);
 $album = clean_itunes_string($album);
 $link = "http://itunes.com/{$artist}/{$album}?partnerId=30&siteID={$affiliate_id}";
 return $link;
}

function clean_itunes_string($string) {
 $string = strtolower(str_replace(' ', '', $string)); //remove whitespace and makes everything lower-case
 $string = str_replace('&', 'and', $string); //Replace ampersands with the word 'and'
 $remove = array('!', '¡', '"', '#', '$', '%', '\'', '(', ')', '*', '+', ',', '\\', '-', '.', '/', ':', ';', '<', '=', '>', '¿', '?', '@', '[', ']', '^', '_', '`', '{', '|', '}', '~', '©', '®', '™');
 $string = str_replace($remove, '', $string); //Remove special characters that iTunes doesn't like
 return $string;
}

echo get_itunes_link('Feist', 'The Reminder');

Note: iTunes links should not have accented characters like á or ü. They should be replaced with their base ASCII counterparts (“a” and “u” respectively). The above code does nothing to sanitize these characters, so you might run into problems unless you write some additional logic to handle that. If you’re using a framework like Kohana, you might have a convenient helper function like utf8::transliterate_to_ascii().

Smashing Magazine Publishes a New WordPress Theme Roundup for 2010

Some of Smashing Magazine’s most popular posts have been their roundups of free WordPress themes. It has been about a year since the last one, and most of the themes featured are looking kind of dated. I was surprised to see a new roundup…

EpicWin: A To-Do List App With an RPG Theme

To-do lists are a great way to organize yourself and make sure you get things done on time. Unfortunately, I have trouble getting into the habit of using a list on a regular basis. The new iPhone app EpicWin attempts to solve that problem.…

BlogBuzz August 21, 2010

Apple’s iAd Platform the “Most Progressive Thing to Date” in Online Advertising

“We feel pretty strongly that this is the way to capitalize on where the mobile Web is heading,” said Chad Jacoby, a senior manager of Nissan’s media operations. “What iAd promises is the most progressive thing I’ve seen to date” in digital advertising. Advertisers…

PHP 5.3.3 Adds PHP-FPM

If you run alternative server software like NGINX or Lighttpd instead of Apache, you know very well about how you need to run PHP as a standalone FastCGI daemon. (This is because there is no equivalent to Apache’s mod_php.) If you have the faintest…

HootSuite Adds Paid Plans

HootSuite, the “social media dashboard” has just announced their new premium accounts. There is still a free option, though you will need to fork over some cash if you need “team members” (collaborators who can post to your shared social media profiles) or more…

BlogBuzz August 14, 2010

Twitter Launches Their Own “Tweet” Button

TweetMeme‘s ubiquitous “retweet” button is being replaced by an official “Tweet” button hosted by Twitter. The button looks good and is very customizable, while providing a more cohesive Twitter experience. In case you were wondering what TweetMeme thinks of this, it seems that Twitter…

Anthologize — Turn Your Blog into an eBook

Anthologize is an interesting new WordPress plugin that helps you compile an eBook using posts from your blog. It supports the PDF, ePub and TEI formats. Anthologize is a free, open-source, plugin that transforms WordPress 3.0 into a platform for publishing electronic texts. Grab…