line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Shorten::MahewinSexyUrl; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26911
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw( WWW::Shorten::generic Exporter ); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2074
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw( makeashorterlink makealongerlink ); |
8
|
|
|
|
|
|
|
our $VERSION = '0.2'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
74759
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
373
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub makeashorterlink ($) { |
13
|
0
|
0
|
|
0
|
1
|
|
my $url = shift or croak 'No URL passed to makeashorterlink'; |
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
|
0
|
|
|
|
|
return undef unless $resp->header('X-ShortUrl'); |
23
|
0
|
|
|
|
|
|
return $service_url . '/' . $resp->header('X-ShortUrl'); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub makealongerlink ($) { |
27
|
0
|
0
|
|
0
|
1
|
|
my $msud = shift or croak 'No msud key / url passed to makealongerlink'; |
28
|
0
|
|
|
|
|
|
my $ua = __PACKAGE__->ua(); |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
$msud = "http://msud.pl/$msud" unless $msud =~ m/^http:\/\//i; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $resp = $ua->get($msud); |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
return undef unless $resp->is_redirect; |
35
|
0
|
|
|
|
|
|
my $url = $resp->header('Location'); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return $url; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |