| 1 | package WWW::Shorten::MahewinSexyUrl; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use base qw( WWW::Shorten::generic Exporter ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | our @EXPORT = qw( makeashorterlink makealongerlink ); | |||||||||
| 8 | 2 | our $VERSION = '0.2'; | |||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 0 | ▶ | sub makeashorterlink ($) { | ||||||||
|
Subroutine
makeashorterlink: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 13 | 0 | ▶ | my $url = shift or croak 'No URL passed to makeashorterlink'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 0 | my $ua = __PACKAGE__->ua(); | |||||||||
| 15 | 0 | my $service_url = 'http://msud.pl'; | |||||||||
| 16 | |||||||||||
| 17 | 0 | my $resp = $ua->post($service_url, [ | |||||||||
| 18 | sexy_url => $url, | ||||||||||
| 19 | source => "PerlAPI-$VERSION", | ||||||||||
| 20 | ]); | ||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | return undef unless $resp->header('X-ShortUrl'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 0 | return $service_url . '/' . $resp->header('X-ShortUrl'); | |||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 0 | ▶ | sub makealongerlink ($) { | ||||||||
|
Subroutine
makealongerlink: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 27 | 0 | ▶ | my $msud = shift or croak 'No msud key / url passed to makealongerlink'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | my $ua = __PACKAGE__->ua(); | |||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | $msud = "http://msud.pl/$msud" unless $msud =~ m/^http:\/\//i; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | 0 | my $resp = $ua->get($msud); | |||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | return undef unless $resp->is_redirect; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 0 | my $url = $resp->header('Location'); | |||||||||
| 36 | |||||||||||
| 37 | 0 | return $url; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 2 | 1; | |||||||||
| 41 | |||||||||||
| 42 | __END__ | ||||||||||