Posts Tagged ‘TinyURL’

URL Shortening Tour

Monday, October 12th, 2009

Have you ever wanted a tour of some of the top URL shortening services? Take this short safari and sit back as you visit fifteen different shortening services!

Watch it carefully, because some go by very quickly.
Take the tour

(Used: bit.ly, a.gd, notlong, metamark, snipurl, socuteurl, lin.cr, urLuv.in/it, b23.ru, tinyarro.ws, icanhaz, ohurl, tinyurl, is.gd, u.nu)

More Twitter?

Monday, May 11th, 2009

“Not again!” you all groan. Well, a couple of you.

I was thinking about URL shortening again, and then I realized that what everyone has been thinking about misses the mark just a little. Sure, you could set up something where you enter your site-admin or an FTP window or whatever, and then edit a file to include one more line, but the odds are it’s not you who’s going to use the service. What if you had a path to your shortening service (.com/shortener.php) that you could give a service like Twitter, and then Twitter could take your long URLs you enter from your mobile device while you’re somewhere doing something that leaves you in no mood to try hacking that into your website first.
What if you could just put yoursite.com/shortener.php into a box on your settings page, and if you happened to tweet a long string it would just use that service, instead of sending it to TinyURL?

If you put it in those terms, your requirements for your shortener change. It must accept a value from a site (probably as a POST variable), maybe check if it’s actually a URL, certainly check if it came from a list of allowed sites (you don’t want some random person throwing spam link into there, to use on other people), write that to an index, generate a new short URL, save that to the index, and then send the result back to the requesting site.

Then that site can put your shortened URL in place of the longer one, and you don’t have to worry about completely-ambiguous URLs; only mostly-ambiguous URLs.
It’ll give you the peace of mind that someone will at least know what site they’re going to, just by looking at the link.

As for the ‘how’: I’ll get to that later. I have to try some things out with PHP, first.

Twitter? PHP? Yes!

Wednesday, April 29th, 2009

I’ve heard from a lot of people that twitter shortens URLs, apparently if they’re more than 30 characters. This means that something like http://www.yoursite.com/images/ would take the full 30, even without an image. I’ve taken a look into what you can do to shorten the URLs you use for your own images:

  1. Top-level domains: If you use http://yoursite.com instead of http://www.yoursite.com, you can slash four characters
  2. Root image folder: If you place a folder for your twitter images in your root, you can point to that folder, such as http://yoursite.com/i or http://yoursite.com/img
  3. Invisible PHP: If you have a index.php in your folder, you can go to http://yoursite.com/i/ and the server will find the index for you. Send it parameters, such as i for image name, and either g, p, or j for .gif, .png, or .jpg, respectively: http://yoursite.com/i/?i=pp1&p

In that final example, the URL is exactly thirty characters long.

For those who want to the PHP script, I have it below:

list($key, $value) = each($_GET);
if(isset($key) && $key != 'p' && $key != 's' && $key != 'm' && $key != 'cat')
{ //wordpress uses 'p', 's', 'm', and 'cat' for posts

$pretension = "<img src='img/twitter/";
$extension = ".bmp' />";
$flag=1;
if(isset($_GET['g']))
$extension = ".gif' />";
elseif(isset($_GET['p']))
$extension = ".png' />";
elseif(isset($_GET['j']))
$extension = ".jpg' />";
elseif(isset($_GET['h']))
$flag=2;

if($flag==2)
header("Location: http://www.".$key.".com/");
else
echo $pretension . $key . $extension;

}else{/*do regular index stuff */}

In this snippet, I paste it before the stuff of my wordpress index. certain GET keys are taken by WordPress, so those can never be my first key. As long as it isn’t, it’ll accept it as a short url, and you can use ‘p’ or ‘cat’ or such as the second or later key. Go to http://icosidodecahedron.com/?s2a&p to try it out. I’ve set it up so that ‘s’ means the sites I’ve made (I’ve made two, so 1 and 2), followed by a design revision (I only have one recorded on s1, but I have four revisions on s2). So try changing that from s2a to s2b, s2c, or s2d. The ‘p’ at the end denotes a .png file. If you put ‘h’, it’ll take it as an HTML page and redirect you.

If you’re the intensive type, you could set up an array on that page which will match the $key to a list of longer filenames in an associative array, which would let you not rename everything. If you’re referring to other sites, you’ll have to do this.

The way I see it, the shortest you could go is to put www.site.ca/?x
in which you have a maximum of 62 links ($key, from the above PHP example, would be a-z, 0-9, or A-Z), all of a pre-determined type. You could get a four-letter domain-name and something like .ca to shorten it further. Overkill? Yes; but I’m just saying, thirteen characters are possible.

So here’s the challenge: make yourselves or your clients a page where you upload an image, that image is placed in a ‘twitter’ folder in the images directory, the filename is added to the array, the user is given a link to paste, and the there’s some $_GET code in the index.php file that takes a visitor to the content described by the link. I’ll have to throw my own implementation up, though it would be completely useless for twitter while I have such a name as icosidodecahedron (seventeen characters).
I’ll try importing html files, too.