Anyone who tweets or sends URL’s in emails likes short URL’s for different reasons. Twitter users like ‘em because of the 140 char limit for tweets.  You don’t want to use all 140 chars allocation on some –you also need a few to hint what it IS! Programmatic  email senders like ‘em because they fit on one .  Is there an to do this under program control?

When the Tix•R•Us business was going we had a program that would send a customer an encoded and necessarily long custom so that they could access the file containing their printable ticket.   I can’t tell you the number of tickets we had  when some lame broke the long  URL into two lines and then clicking just the first didn’t work and the customer couldn’t figure it out.

TinyURL and other crunchers of that ilk exist exactly for this purpose; in fact many tools automatically the URL’s when you use them to tweet.   You can even a to easily tinify any URL you might happen to be on.   I thought surely there must be an for this, but you don’t see mention of one on ’s web at all.  I tried using to to the receiver that ’s form goes to (it is called create.) but that did not work. Then I found out they have a trivial they just don’t tell us about it! You have to append a  simple to -create. as shown below,  rather than to create., (i.e. you use the method) –even easier!

Here is a trivial program to do it.   Hint: if you want to use the code, copy/paste it into your own app and the cut-off part will show.  If you don’t you probably don’t care what it is anyway.  :)

 ($url) {
   if (($result = file_get_contents('http://.com/-create.?url='.$url))  === false) {
        throw new ( "Can't tinify $url " );
    }
    return($result);
}
//tiny calling shell, obviously you'd want to  the URL from a form in the real world
try {
    echo ("http://food.dorkage.net");
} catch ( $e) {
    echo "caught  " ,  $e->getMessage() , "\n";
}

Listen to this post Listen to this post

Related posts