Ever wanted to lengthen URLs from URL shorteners before including them in your site? Worry no more!

urlShortener::toLong attempts to look up shortening services and retrieve the original URL. If there's an error, it just returns the short URL. Many issues can cause the original being returned, from unsupported services to malformed output. If it's successful, you'll receive the longer, original URL back.

If a URL has been passed through multiple supported URL shorteners, this code should go through them all until it gets the original.

If there's a URL shortener service not supported here, and you'd like it to be, reply to the post and I'll see what I can do. I've not implemented any service that uses splash pages or frames, and would rather not due to the added complexity.

PHP Code:

EURLSHORTENER extends Exception {}
urlShortener {
supportedTypes ';1u.ro;1url.com;2tu.us;3.ly;adjix.com;altulr.com;b23.ru;bacn.me;bit.ly;cd4.me;chilp.it;chs.mx;cli.gs;cort.as;doiop.com;fa.by;fb.me;flq.us;fly2.ws;fwd4.me;goo.gl;href.in;hurl.ws;idek.net;is.gd;kl.am;korta.nu;lamped.co.uk;liip.to;liltext.com;linkbee.com;liurl.cn;ln-s.net;ln-s.ru;lru.jp;lt.tl;migre.me;miniurl.com;minu.me;www.minu.me;moourl.com;nn.nf;o-x.fr;omf.gd;ow.ly;pnt.me;rb6.me;redirx.com;retwt.me;ri.ms;rickroll.it;short.ie;shrtl.com;simurl.net;simurl.org;simurl.us;sn.im;snipr.com;snipurl.com;snurl.com;sp2.ro;spedr.com;starturl.com;tighturl.com;tiny.cc;tiny.pl;tinyurl.com;to.ly;togoto.us;tr.im;twurl.nl;u.nu;ur1.ca;url.co.uk;url.ie;urlcut.com;urlkiss.com;vl.am;wa9.la;wapurl.co.uk;wipi.es;wp.me;xeeurl.com;xr.com;xrl.in;xrl.us;xurl.jp;ye-s.com;yep.it;zi.pe;zz.gd;';
    static function 
toLong($url) {
        if (
preg_match('/^http:\/\/([a-z0-9\.\-]+)\/([a-z0-9\/_\.\?\-]+)/i'$url$info) && (strpos(self::supportedTypes';'.$info[1].';') !== False)) {
            if (
$handle fsockopen($info[1], 80)) {
'GET /'.$info[2].' HTTP/1.1'."\r\n".
'Host: '.$info[1]."\r\n".
'User-Agent: Mozilla/5.0 (compatible; LampedWeb/'.LAMPED_URLSHORTENER.')'."\r\n".
'Accept: */*'."\r\n".
'Connection: close'."\r\n".
                while (!
$data .= fgets($handle512);
$data explode("\r\n"$data);
                foreach (
$data as $line)
                    if (
strtolower(substr($line017)) == 'location: http://') {
$redir trim(substr($line10255));
                        if (
preg_match('/^http:\/\/([a-z0-9\.\-]+)/i'$redir$match) && (strpos(self::supportedTypes';'.$match[1].';') !== False))

    static function 
getSupported() {
$hosts explode(';'self::supportedTypes);
array_shift($hosts); // Account for 2 blank entries from pre/post-fix ;

Why are there 2 minu.me entries?

minu.me issues a redirect to www.minu.me where the real Location is given. Having both entries allows the internal recursion to recognise www.minu.me

This code is unlicensed and free to use for any purpose, with or without credit.