NAME
WWW::Lengthen - lengthen 'shortened' urls
SYNOPSIS
use WWW::Lengthen;
my $lenghtener = WWW::Lenghten->new;
my $lengthened_url = $lengthener->try($url);
# if you find some new and unsupported shortener service
$lengthener->add( ServiceName => qr{^http://service.com/} );
# or you may add some known extra services
$lengthener->add( %WWW::Lengthen::ExtraServices );
DESCRIPTION
There are a bunch of URL shortening services around the world. They have slightly different APIs to shorten URLs but the lengthening part is always the same: follow the shortened URL and see the redirect.
This module tries all the known services to find a longer URL. You may say we can do it with WWW::Shorten family but you can't say which services people use to shorten URLs. You can select some specific shortening service for your website to shorten longer URLs automatically, but spammers may post URLs shortened with other shortening services to avoid offensive URLs they post to be disclosed by clever client tools that know which shortening service your site uses.
Well, this is a cat and mouse game but I hope this help you a bit, at least to save time copying and pasting to create another WWW::Shorten subclass and load it just to lengthen URLs.
METHODS
new
creates an object. Optionally you can pass an array of services to check if you want some more speed.
try
takes a (probably shortened) URL and find a longer URL. If not found, just returns the original URL.
add
takes a hash whose keys are service names and whose values are regexen to see if the tried URL should belong to the service or not. Preferably we should exclude API URLs but usually it doesn't matter as nothing would happen if we just GET them.
Several shorten services use special techniques to resolve links, such as multiple redirection or page refreshing. WWW::Lengthen doesn't support them natively at the moment, but if there's WWW::Shorten subclass, you can use it to lengthen like this:
$self->add( Name => [ qr{^http://service.com/}, 'WWW::Shorten::ServiceName' ] );
ua
returns an LWP::UserAgent object used internally.
SUPPORTED SERVICES
Natively
- 0rz (http://0rz.tw/)
- haojp (http://hao.jp/)
- Metamark (http://xrl.us/)
- NotLong (http://notlong.com/)
- ShortenURL (http://www.shortenurl.com/)
- Smallr (http://smallr.com/)
- SnipURL (http://snipurl.com/)
- TinyURL (http://tinyurl.com/)
- urlTea (http://urltea.com/)
- Snurl (http://snurl.com/)
Require WWW::Shorten subclasses
Dead/Down/Too Heavy when I tested
not tested but probably works with WWW::Shorten subclasses.
- BabyURL (http://babyurl.com/)
- Linkz (http://lin.kz/)
- Shorl (http://shorl.com/) # was too heavy
- TinyClick (http://tinyclick.com/)
- V3 (http://www.v3.net/)
SEE ALSO
AUTHOR
Kenichi Ishigaki, <ishigaki@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2007 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.