line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
sub Mojo::Webqq::Model::_get_friends_state { |
2
|
0
|
|
|
0
|
|
|
my $self = shift; |
3
|
0
|
|
|
|
|
|
my $callback = shift; |
4
|
0
|
|
|
|
|
|
my $api_url = 'http://d1.web2.qq.com/channel/get_online_buddies2'; |
5
|
0
|
|
|
|
|
|
my $headers = { |
6
|
|
|
|
|
|
|
Referer => 'http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2', |
7
|
|
|
|
|
|
|
json => 1, |
8
|
|
|
|
|
|
|
}; |
9
|
0
|
|
|
|
|
|
my @query_string = ( |
10
|
|
|
|
|
|
|
vfwebqq => $self->vfwebqq, |
11
|
|
|
|
|
|
|
clientid => $self->clientid, |
12
|
|
|
|
|
|
|
psessionid => $self->psessionid, |
13
|
|
|
|
|
|
|
t => time, |
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
|
|
|
|
|
|
for(@{$json->{result}}){ |
|
0
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
$_->{client_type} = $self->code2client($_->{client_type}); |
22
|
0
|
|
|
|
|
|
$_->{state} = $_->{status}; |
23
|
0
|
|
|
|
|
|
delete $_->{status}; |
24
|
|
|
|
|
|
|
} |
25
|
0
|
|
|
|
|
|
return $json->{result}; |
26
|
0
|
|
|
|
|
|
}; |
27
|
0
|
0
|
|
|
|
|
if($is_blocking){ |
28
|
0
|
|
|
|
|
|
return $handle->( $self->http_get($self->gen_url($api_url,@query_string),$headers,) ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
else{ |
31
|
|
|
|
|
|
|
$self->http_get($self->gen_url($api_url,@query_string),$headers,sub{ |
32
|
0
|
|
|
0
|
|
|
my $json = shift; |
33
|
0
|
|
|
|
|
|
$callback->( $handle->($json)); |
34
|
0
|
|
|
|
|
|
}); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
1; |