line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
sub Mojo::Webqq::Model::_get_recent_info { |
2
|
0
|
|
|
0
|
|
|
my $self = shift; |
3
|
0
|
|
|
|
|
|
my $callback = shift; |
4
|
0
|
|
|
|
|
|
my $api_url = 'http://d1.web2.qq.com/channel/get_recent_list2'; |
5
|
0
|
|
|
|
|
|
my $headers = { |
6
|
|
|
|
|
|
|
Referer => 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2', |
7
|
|
|
|
|
|
|
json => 1, |
8
|
|
|
|
|
|
|
}; |
9
|
|
|
|
|
|
|
|
10
|
0
|
|
|
|
|
|
my %r = ( |
11
|
|
|
|
|
|
|
vfwebqq => $self->vfwebqq, |
12
|
|
|
|
|
|
|
clientid => $self->clientid, |
13
|
|
|
|
|
|
|
psessionid => $self->psessionid, |
14
|
|
|
|
|
|
|
); |
15
|
0
|
0
|
|
|
|
|
my $is_blocking = ref $callback eq "CODE"?0:1; |
16
|
|
|
|
|
|
|
my $handle = sub{ |
17
|
0
|
|
|
0
|
|
|
my $json = shift; |
18
|
0
|
0
|
|
|
|
|
return undef unless defined $json; |
19
|
0
|
0
|
|
|
|
|
return undef if $json->{retcode}!=0 ; |
20
|
0
|
|
|
|
|
|
my %type = (0 => 'friend',1 => 'group', 2 => 'discuss'); |
21
|
0
|
|
|
|
|
|
my @recent; |
22
|
0
|
|
|
|
|
|
for(@{$json->{result}}){ |
|
0
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
next unless exists $type{$_->{type}}; |
24
|
0
|
|
|
|
|
|
$_->{type} = $type{$_->{type}}; |
25
|
0
|
0
|
|
|
|
|
if($_->{type} eq "friend"){$_->{id} = delete $_->{uin};} |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
elsif($_->{type} eq "group"){$_->{id} = delete $_->{uin};} |
27
|
0
|
|
|
|
|
|
elsif($_->{type} eq "discuss"){$_->{id} = delete $_->{uin};} |
28
|
0
|
|
|
|
|
|
push @recent,$_; |
29
|
|
|
|
|
|
|
} |
30
|
0
|
0
|
|
|
|
|
return @recent>0?\@recent:undef; |
31
|
0
|
|
|
|
|
|
}; |
32
|
0
|
0
|
|
|
|
|
if($is_blocking){ |
33
|
0
|
|
|
|
|
|
return $handle->( $self->http_post($api_url,$headers,form=>{r=>$self->to_json(\%r)},) ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else{ |
36
|
|
|
|
|
|
|
$self->http_post($api_url,$headers,form=>{r=>$self->to_json(\%r)},sub{ |
37
|
0
|
|
|
0
|
|
|
my $json = shift; |
38
|
0
|
|
|
|
|
|
$callback->( $handle->($json) ); |
39
|
0
|
|
|
|
|
|
}); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
1; |