Webqq/Client/Method/_get_friends_state.pm

filter: Statementstmt 25.0% 7 / 28 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 20.9% 9 / 43 CC 8 SCAR 40.6
CC
8
Cov
18%
_get_friends_state
72.0
BEGIN
1.0
BEGIN
1.0
CRAP 57.8
« Webqq/Client/Method/_get_user_info.pm ↑ Summary Webqq/Client/Method/get_qq_from_uin.pm »
1 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Webqq::Client::Util qw(code2state code2client);
Subroutine BEGIN: called CC=1 SCAR=0.0
3 0 ▶sub Webqq::Client::_get_friends_state {
Subroutine _get_friends_state: not called CC=8 SCAR=42.8
4 0 my $self = shift;
5 0 ▶ return undef if $self->{type} ne 'smartqq';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type"} ne "smartqq" 0 0 0
6 0 my $ua = $self->{ua};
7 0 my $api_url = 'http://d.web2.qq.com/channel/get_online_buddies2';
8 0 my @headers = (
9 Referer=>'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2'
10 );
11 my @query_string = (
12 vfwebqq => $self->{qq_param}{vfwebqq},
13 clientid => $self->{qq_param}{clientid},
14 psessionid => $self->{qq_param}{psessionid},
15 0 t => time,
16 );
17 0 my @query_string_pairs;
18 0 ▶ push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string);
Branch: 1 branch
BranchTrueFalseTotal
@query_string and do { push @query_string_pairs, shift(@query_string) . '=' . shift(@query_string) } 0 0 0
19 0 ▶ print "GET $api_url\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
20 0 my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers);
21 0 ▶ if($response->is_success){
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) { } 0 0 0
22 0 ▶ print $response->content(),"\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
23 0 my $json = JSON->new->utf8->decode( $response->content() );
24 0 ▶ return undef if $json->{retcode} !=0;
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"retcode"} != 0 0 0 0
25 0 for(@{$json->{result}}){
26 0 $_->{client_type} = code2client($_->{client_type});
27 0 $_->{state} = $_->{status};
28 0 delete $_->{status};
29 }
30 0 return $json->{result};
31 }
32 0 else{return undef}
33 }
34 1 1;
« Webqq/Client/Method/_get_user_info.pm ↑ Summary Webqq/Client/Method/get_qq_from_uin.pm »