| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Social; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
777
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
52
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
59
|
|
|
5
|
1
|
|
|
1
|
|
15
|
use base qw(Exporter); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
87
|
|
|
6
|
1
|
|
|
|
|
8
|
use Module::Pluggable search_path => 'Net::Social::Service', |
|
7
|
|
|
|
|
|
|
sub_name => '_fetch_services', |
|
8
|
1
|
|
|
1
|
|
883
|
instantiate => 'new'; |
|
|
1
|
|
|
|
|
11307
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# relationship constants |
|
13
|
1
|
|
|
1
|
|
86
|
use constant NONE => 0x0; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
59
|
|
|
14
|
1
|
|
|
1
|
|
4
|
use constant FRIENDED => 0x1; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
15
|
1
|
|
|
1
|
|
4
|
use constant FRIENDED_BY => 0x2; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
39
|
|
|
16
|
1
|
|
|
1
|
|
5
|
use constant MUTUAL => 0x3; # not strictly needed but convenient |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
314
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
@EXPORT_OK = qw(NONE FRIENDED FRIENDED_BY MUTUAL); |
|
19
|
|
|
|
|
|
|
%EXPORT_TAGS = ( all => [@EXPORT_OK] ); |
|
20
|
|
|
|
|
|
|
$VERSION = 0.4; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Net::Social - abstracted interface for social networks |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Net::Social qw(:all); # get constants |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# What services are available |
|
32
|
|
|
|
|
|
|
my @services = Net::Social->services; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Fetch a handler for a service |
|
35
|
|
|
|
|
|
|
my $service = Net::Social->service('LiveJournal'); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# what fields are needed to login |
|
38
|
|
|
|
|
|
|
my %params = $service->params; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
foreach my $type (keys %params) { |
|
41
|
|
|
|
|
|
|
print "To $type:\n"; # either read or write |
|
42
|
|
|
|
|
|
|
foreach my $p (keys %$types{$type}) { |
|
43
|
|
|
|
|
|
|
print $params{$type}->{$p}->{name}." : ".$params{$type}->{$p}->{description}."\n"; |
|
44
|
|
|
|
|
|
|
# also 'required' and 'sensitive' |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# login - my_params must have the required fields from %params |
|
49
|
|
|
|
|
|
|
$service->login(%my_params); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# now fetch your friends |
|
52
|
|
|
|
|
|
|
my @friends = $service->friends; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# add a friend |
|
55
|
|
|
|
|
|
|
$service->add_friend($friend); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# remove a friend |
|
58
|
|
|
|
|
|
|
$service->remove_friend($friend); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 CONSTANTS |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Optionally exports the constants |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
NONE |
|
66
|
|
|
|
|
|
|
FRIENDED |
|
67
|
|
|
|
|
|
|
FRIENDED_BY |
|
68
|
|
|
|
|
|
|
MUTUAL |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Which describe the type of relationship with a friend. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
It should be noted that |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
MUTUAL = FRIENDED | FRIENDED_BY; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
but is provided for convenience. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 METHODS |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _services { |
|
83
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
84
|
0
|
|
|
|
|
|
my %services; |
|
85
|
0
|
|
|
|
|
|
for my $service ($class->_fetch_services) { |
|
86
|
0
|
|
|
|
|
|
my $name = ref($service); |
|
87
|
0
|
|
|
|
|
|
$name =~ s!^Net::Social::Service::!!; |
|
88
|
0
|
0
|
|
|
|
|
next if $name =~ m!::!; |
|
89
|
0
|
|
|
|
|
|
$services{lc($name)} = $service; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
0
|
|
|
|
|
|
return %services; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
=head2 services |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
A list of all services available. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub services { |
|
100
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
101
|
0
|
|
|
|
|
|
my %services = $class->_services(); |
|
102
|
0
|
|
|
|
|
|
return keys %services; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 service |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Fetch the class for a given service |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns undef if that service isn't found. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub service { |
|
115
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
116
|
0
|
|
|
|
|
|
my $service = shift; |
|
117
|
0
|
|
|
|
|
|
my %services = $class->_services(); |
|
118
|
0
|
|
|
|
|
|
return $services{lc($service)}; |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Simon Wistow |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Copyright, 2007 - Simon Wistow |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Distributed under the same terms as Perl itself |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |