| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Shorten::VGd; |
|
2
|
2
|
|
|
2
|
|
62266
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
55
|
|
|
3
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
62
|
|
|
4
|
2
|
|
|
2
|
|
8
|
use base qw( WWW::Shorten::generic Exporter ); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
497
|
|
|
5
|
|
|
|
|
|
|
our @EXPORT = qw( makeashorterlink makealongerlink ); |
|
6
|
2
|
|
|
2
|
|
34077
|
use Carp (); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
24
|
|
|
7
|
2
|
|
|
2
|
|
831
|
use HTML::Entities; |
|
|
2
|
|
|
|
|
7733
|
|
|
|
2
|
|
|
|
|
524
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.004'; |
|
10
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub makeashorterlink { |
|
13
|
0
|
0
|
|
0
|
1
|
|
my $url = shift or Carp::croak('No URL passed to makeashorterlink'); |
|
14
|
0
|
|
|
|
|
|
my $ua = __PACKAGE__->ua(); |
|
15
|
0
|
|
|
|
|
|
my $response = $ua->post('https://v.gd/create.php', { |
|
16
|
|
|
|
|
|
|
url => $url, |
|
17
|
|
|
|
|
|
|
format => 'simple', |
|
18
|
|
|
|
|
|
|
}); |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
0
|
|
|
|
|
return unless $response->is_success; |
|
21
|
0
|
|
|
|
|
|
my $shorturl = $response->decoded_content(); |
|
22
|
0
|
0
|
|
|
|
|
return if $shorturl =~ m/Error/; |
|
23
|
0
|
0
|
|
|
|
|
if ($response->content =~ m{^(\Qhttps://v.gd/\E\w+)$}) { |
|
24
|
0
|
|
|
|
|
|
return $1; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
0
|
|
|
|
|
|
return; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub makealongerlink { |
|
30
|
0
|
0
|
|
0
|
1
|
|
my $url = shift or Carp::croak('No v.gd key/URL passed to makealongerlink'); |
|
31
|
0
|
|
|
|
|
|
my $ua = __PACKAGE__->ua(); |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
$url =~ s{\Qhttps?://v.gd/\E}{}i; |
|
34
|
0
|
|
|
|
|
|
my $response = $ua->post('https://v.gd/forward.php', { |
|
35
|
|
|
|
|
|
|
shorturl => $url, |
|
36
|
|
|
|
|
|
|
format => 'simple', |
|
37
|
|
|
|
|
|
|
}); |
|
38
|
|
|
|
|
|
|
# use Data::Dumper; |
|
39
|
|
|
|
|
|
|
# print STDERR Dumper $response; |
|
40
|
0
|
0
|
|
|
|
|
return unless $response->is_success; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $longurl = $response->{_content}; |
|
43
|
0
|
|
|
|
|
|
return decode_entities($longurl); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |