line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
4
|
use JSON; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
2
|
1
|
|
|
1
|
|
79
|
use Webqq::Client::Util qw(hash); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
704
|
|
3
|
|
|
|
|
|
|
sub Webqq::Client::_get_user_friends{ |
4
|
0
|
|
|
0
|
|
|
my $self = shift; |
5
|
0
|
|
|
|
|
|
my $api_url = 'http://s.web2.qq.com/api/get_user_friends2'; |
6
|
0
|
|
|
|
|
|
my $ua = $self->{ua}; |
7
|
0
|
0
|
|
|
|
|
my @headers = $self->{type} eq 'webqq'? (Referer=>'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3') |
8
|
|
|
|
|
|
|
: (Referer=>'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1') |
9
|
|
|
|
|
|
|
; |
10
|
0
|
|
|
|
|
|
my %r = ( |
11
|
|
|
|
|
|
|
hash => hash($self->{qq_param}{ptwebqq},$self->{qq_param}{qq}), |
12
|
|
|
|
|
|
|
vfwebqq => $self->{qq_param}{vfwebqq}, |
13
|
|
|
|
|
|
|
); |
14
|
0
|
0
|
|
|
|
|
if($self->{type} eq 'webqq'){ |
15
|
0
|
|
|
|
|
|
$r{"h"} = "hello"; |
16
|
|
|
|
|
|
|
} |
17
|
0
|
|
|
|
|
|
my $response = $ua->post($api_url,[r=>JSON->new->utf8->encode(\%r)],@headers); |
18
|
0
|
0
|
|
|
|
|
if($response->is_success){ |
|
0
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
print $response->content(),"\n" if $self->{debug}; |
20
|
0
|
|
|
|
|
|
my $json = JSON->new->utf8->decode($response->content()); |
21
|
0
|
0
|
|
|
|
|
return undef if $json->{retcode}!=0 ; |
22
|
0
|
|
|
|
|
|
my $friends_state = $self->_get_friends_state(); |
23
|
0
|
|
|
|
|
|
my %categories ; |
24
|
|
|
|
|
|
|
my %info; |
25
|
0
|
|
|
|
|
|
my %marknames; |
26
|
0
|
|
|
|
|
|
my %vipinfo; |
27
|
0
|
|
|
|
|
|
my %state; |
28
|
0
|
0
|
|
|
|
|
if(defined $friends_state){ |
29
|
0
|
|
|
|
|
|
for(@{$friends_state}){ |
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$state{$_->{uin}}{state} = $_->{state}; |
31
|
0
|
|
|
|
|
|
$state{$_->{uin}}{client_type} = $_->{client_type}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
for(@{ $json->{result}{categories}}){ |
|
0
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
$categories{ $_->{'index'} } = {'sort'=>$_->{'sort'},name=>encode("utf8",$_->{name}) }; |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
$categories{0} = {sort=>0,name=>'我的好友'}; |
38
|
0
|
|
|
|
|
|
for(@{ $json->{result}{info}}){ |
|
0
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$info{$_->{uin}} = {face=>$_->{face},flag=>$_->{flag},nick=>encode("utf8",$_->{nick}),}; |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
|
for(@{ $json->{result}{marknames} }){ |
|
0
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$marknames{$_->{uin}} = {markname=>encode("utf8",$_->{markname}),type=>$_->{type}}; |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
for(@{ $json->{result}{vipinfo} }){ |
|
0
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$vipinfo{$_->{u}} = {vip_level=>$_->{vip_level},is_vip=>$_->{is_vip}}; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
for(@{$json->{result}{friends}}){ |
|
0
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $uin = $_->{uin}; |
49
|
0
|
0
|
|
|
|
|
if(exists $state{$_->{uin}}){ |
50
|
0
|
|
|
|
|
|
$_->{state} = $state{$uin}{state}; |
51
|
0
|
|
|
|
|
|
$_->{client_type} = $state{$uin}{client_type}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else{ |
54
|
0
|
|
|
|
|
|
$_->{state} = 'offline'; |
55
|
0
|
|
|
|
|
|
$_->{client_type} = 'unknown'; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
$_->{categorie} = $categories{$_->{categories}}{name}; |
58
|
0
|
|
|
|
|
|
$_->{nick} = $info{$uin}{nick}; |
59
|
0
|
|
|
|
|
|
$_->{face} = $info{$uin}{face}; |
60
|
0
|
|
|
|
|
|
$_->{markname} = $marknames{$uin}{markname}; |
61
|
0
|
|
|
|
|
|
$_->{is_vip} = $vipinfo{$uin}{is_vip}; |
62
|
0
|
|
|
|
|
|
$_->{vip_level} = $vipinfo{$uin}{vip_level}; |
63
|
0
|
|
|
|
|
|
delete $_->{categories}; |
64
|
|
|
|
|
|
|
} |
65
|
0
|
|
|
|
|
|
return $json->{result}{friends}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
else{return undef} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
1; |