| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package URL::Social; |
|
2
|
6
|
|
|
6
|
|
205664
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use namespace::autoclean; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use URL::Social::Facebook; |
|
6
|
|
|
|
|
|
|
use URL::Social::LinkedIn; |
|
7
|
|
|
|
|
|
|
use URL::Social::Reddit; |
|
8
|
|
|
|
|
|
|
use URL::Social::StumbleUpon; |
|
9
|
|
|
|
|
|
|
use URL::Social::Twitter; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
URL::Social - Helper module for retrieving social information (likes, shares |
|
14
|
|
|
|
|
|
|
etc.) for any given URL. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 VERSION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Version 0.07 |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This module makes it easy to extract social information like likes, shares |
|
27
|
|
|
|
|
|
|
etc. for any given URL from the following services: |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
* Facebook |
|
30
|
|
|
|
|
|
|
* LinkedIn |
|
31
|
|
|
|
|
|
|
* Reddit |
|
32
|
|
|
|
|
|
|
* StumbleUpon |
|
33
|
|
|
|
|
|
|
* Twitter |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use URL::Social; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $social = URL::Social->new( |
|
40
|
|
|
|
|
|
|
url => '...', |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $facebook_shares = $social->facebook->share_count; |
|
44
|
|
|
|
|
|
|
my $twitter_shares = $social->twitter->share_count; |
|
45
|
|
|
|
|
|
|
# ... |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 METHODS |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 new( url => $url ) |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Returns an instance of this class. Requires C<$url> as an argument; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $social = URL::Social->new( |
|
54
|
|
|
|
|
|
|
url => '...', |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has 'url' => ( isa => 'Str', is => 'ro', required => 1, default => '' ); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has 'facebook' => ( isa => 'URL::Social::Facebook', is => 'ro', lazy_build => 1 ); |
|
62
|
|
|
|
|
|
|
has 'linkedin' => ( isa => 'URL::Social::LinkedIn', is => 'ro', lazy_build => 1 ); |
|
63
|
|
|
|
|
|
|
has 'reddit' => ( isa => 'URL::Social::Reddit', is => 'ro', lazy_build => 1 ); |
|
64
|
|
|
|
|
|
|
has 'stumbleupon' => ( isa => 'URL::Social::StumbleUpon', is => 'ro', lazy_build => 1 ); |
|
65
|
|
|
|
|
|
|
has 'twitter' => ( isa => 'URL::Social::Twitter', is => 'ro', lazy_build => 1 ); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 facebook |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns an instance of the L<URL::Social::Facebook> class. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _build_facebook { |
|
74
|
|
|
|
|
|
|
my $self = shift; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
return URL::Social::Facebook->new( url => $self->url ); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 linkedin |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns an instance of the L<URL::Social::LinkedIn> class. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _build_linkedin { |
|
86
|
|
|
|
|
|
|
my $self = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
return URL::Social::LinkedIn->new( url => $self->url ); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 reddit |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Returns an instance of the L<URL::Social::Reddit> class. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _build_reddit { |
|
98
|
|
|
|
|
|
|
my $self = shift; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
return URL::Social::Reddit->new( url => $self->url ); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 stumbleupon |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Returns an instance of the L<URL::Social::StumbleUpon> class. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _build_stumbleupon { |
|
110
|
|
|
|
|
|
|
my $self = shift; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
return URL::Social::StumbleUpon->new( url => $self->url ); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 twitter |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Returns an instance of the L<URL::Social::Twitter> class. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _build_twitter { |
|
122
|
|
|
|
|
|
|
my $self = shift; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
return URL::Social::Twitter->new( url => $self->url ); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# |
|
128
|
|
|
|
|
|
|
# The End |
|
129
|
|
|
|
|
|
|
# |
|
130
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 TODO |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
* Improve tests, as the current tests do live requests. |
|
137
|
|
|
|
|
|
|
* Add support for more social APIs; Google+, Pinterest, Disqus etc. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 BUGS |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Most probably. Please report any bugs at http://rt.cpan.org/. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Copyright 2013-2014 Tore Aursand. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
148
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
|
149
|
|
|
|
|
|
|
copy of the full license at: |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L<http://www.perlfoundation.org/artistic_license_2_0> |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
|
154
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
|
155
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
|
156
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
|
159
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
|
160
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
|
163
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
|
166
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
|
167
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
|
168
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
|
169
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
|
170
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
|
171
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
|
172
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
|
175
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
|
176
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
177
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
|
178
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
|
179
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
|
180
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
|
181
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |