line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Social::Mapper::Persona::Myspace; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2211
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
53
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw(Net::Social::Mapper::Persona::Generic); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1346
|
|
5
|
1
|
|
|
1
|
|
12
|
use URI; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
6
|
1
|
|
|
1
|
|
1377
|
use Data::Dumper; |
|
1
|
|
|
|
|
7473
|
|
|
1
|
|
|
|
|
564
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Net::Social::Mapper::Person::Myspace - the persona for a Myspace account |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head2 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
See C |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _init { |
20
|
0
|
|
|
0
|
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Guess at a bunch of stuff |
23
|
0
|
|
|
|
|
|
$self = $self->SUPER::_init; |
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
my $id = ($self->{user} =~ m!^\d+$!) ? $self->{user} : $self->_fetch_id; |
26
|
0
|
|
|
|
|
|
$self->{id} = $id; |
27
|
0
|
|
|
|
|
|
$self->{profile} = $self->{homepage} = "http://myspace.com/".$self->{user}; |
28
|
0
|
0
|
|
|
|
|
$self->{feeds} = defined $id? [ "http://blogs.myspace.com/Modules/BlogV2/Pages/RssFeed.aspx?friendID=".$self->{id} ] : []; |
29
|
0
|
|
|
|
|
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _fetch_id { |
33
|
0
|
|
|
0
|
|
|
my $self = shift; |
34
|
0
|
|
0
|
|
|
|
return $self->_fetch_id_from_google || $self->_fetch_id_from_page || undef; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _fetch_id_from_google { |
38
|
0
|
|
|
0
|
|
|
my $self = shift; |
39
|
0
|
|
|
|
|
|
my $page = $self->{homepage}; $page =~ s!/+$!!; |
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my %params = ( q => $page ); |
41
|
0
|
|
|
|
|
|
my $url = URI->new("http://socialgraph.apis.google.com/lookup"); |
42
|
0
|
|
|
|
|
|
$url->query_form(%params); |
43
|
0
|
|
0
|
|
|
|
my $data = $self->mapper->get("$url") || return; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $res = eval { $self->_json->decode($data) }; |
|
0
|
|
|
|
|
|
|
46
|
0
|
|
0
|
|
|
|
my $node = $res->{nodes}->{$page} || {}; |
47
|
0
|
|
0
|
|
|
|
my $rss = $node->{attributes}->{rss} || return; |
48
|
0
|
|
|
|
|
|
my ($id) = ($rss =~ m!friendID=(\d+)!i); |
49
|
0
|
|
|
|
|
|
return $id; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _fetch_id_from_page { |
53
|
0
|
|
|
0
|
|
|
my $self = shift; |
54
|
0
|
|
|
|
|
|
my $page = $self->{homepage}; |
55
|
0
|
|
0
|
|
|
|
my $data = $self->mapper->get("$page") || return; |
56
|
0
|
|
|
|
|
|
my ($id) = ($data =~ m!"DisplayFriendId":(\d+)!); |
57
|
0
|
|
|
|
|
|
return $id; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|