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/)
- Metamark (http://xrl.us/)
- SnipURL (http://snipurl.com/)
- TinyURL (http://tinyurl.com/)
- Snurl (http://snurl.com/)
- bit.ly (http://bit.ly/)
- is.gd (http://is.gd/)
- ow.ly/ht.ly (http://ow.ly/)
- urlchen (http://urlchen.de/)
- google (http://goo.gl/)
Require WWW::Shorten subclasses
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.