| WWW-Shorten-Smallr documentation | Contained in the WWW-Shorten-Smallr distribution. |
WWW::Shorten::Smallr - Perl interface to Smallr.com
use WWW::Shorten::Smallr; use WWW::Shorten 'Smallr'; my $short_url = makeashorterlink($long_url);
A Perl interface to the web site Smallr.com. Smallr maintains a database of long URLs, each of which has a unique identifier.
The function makeashorterlink will call the Smallr.com web site,
pass it your long URL, and return the shortened version.
makeashorterlink
See the main WWW::Shorten docs.
Dean Wilson <dean.wilson@gmail.com>
WWW::Shorten, perl, http://smallr.com/
| WWW-Shorten-Smallr documentation | Contained in the WWW-Shorten-Smallr distribution. |
package WWW::Shorten::Smallr; use strict; use warnings; use Carp; use base qw( WWW::Shorten::generic Exporter ); our @EXPORT = qw(makeashorterlink); our $VERSION = '0.01';
sub makeashorterlink ($) { my $smallr = 'http://smallr.com/url/make'; my $base_url = 'http://smallr.com/'; my $url = shift or croak 'No URL passed to makeashorterlink'; my $ua = __PACKAGE__->ua(); my $resp = $ua->post($smallr, [ url => $url, submit => 'submit' ]); return unless $resp->is_success; if ($resp->content =~ m!<h2 id="shortUrl"><a href="/(.*?)"!) { #if ($resp->content =~ m!Your shorter link is: <a href="(.*?)">!) { return "$base_url$1"; } return; } 1; __END__