Webqq/Client/Method/_get_friend_info.pm

filter: Statementstmt 21.2% 7 / 33 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 17.3% 9 / 52 CC 10 SCAR 45.2
CC
10
Cov
14%
_get_friend_info
110.0
BEGIN
1.0
BEGIN
1.0
CRAP 91.8
« Webqq/Client.pm ↑ Summary Webqq/Client/Method/_get_discuss_list_info.pm »
1 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Webqq::Client::Util qw(code2state);
Subroutine BEGIN: called CC=1 SCAR=0.0
3 0 ▶sub Webqq::Client::_get_friend_info{
Subroutine _get_friend_info: not called CC=10 SCAR=47.0
4 0 my $self = shift;
5 0 my $uin = shift;
6 0 my $api_url = 'http://s.web2.qq.com/api/get_friend_info2';
7 0 my $ua = $self->{ua};
8 0 ▶ my @headers = $self->{type} eq 'webqq'? (Referer=>'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3')
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'} eq 'webqq' ? : 0 0 0
9 : (Referer=>'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1')
10 ;
11 my @query_string = (
12 tuin => $uin,
13 vfwebqq => $self->{qq_param}{vfwebqq},
14 clientid => $self->{qq_param}{clientid},
15 psessionid => $self->{qq_param}{psessionid},
16 0 t => time,
17 );
18  
19 0 ▶ if($self->{type} eq 'webqq'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "webqq") 0 0 0
20 @query_string = (
21 tuin => $uin,
22 verifysession => undef,
23 code => undef,
24 vfwebqq => $self->{qq_param}{vfwebqq},
25 0 t => time,
26 );
27 }
28 0 my @query_string_pairs;
29 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
30 0 my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers);
31 0 ▶ if($response->is_success){
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) { } 0 0 0
32 0 ▶ print $response->content(),"\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
33 0 my $json = JSON->new->utf8->decode( $response->content() );
34 0 ▶ return undef if $json->{retcode} !=0;
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"retcode"} != 0 0 0 0
35 0 my $user_info = $json->{result};
36 0 for my $key (keys %{ $user_info }){
37 0 ▶ if($key eq 'birthday'){
Branch: 2 branches
BranchTrueFalseTotal
if ($key eq 'birthday') { } 0 0 0
elsif ($key eq 'stat') { } 0 0 0
38 $user_info->{$key} =
39 0 encode("utf8", join("-",@{ $user_info->{birthday}}{qw(year month day)} ) );
40 }
41 elsif($key eq 'stat'){
42 0 $user_info{state} = code2state($user_info->{'stat'});
43 }
44 else{
45 0 $user_info->{$key} = encode("utf8",$user_info->{$key});
46 }
47 }
48 0 delete $user_info->{'stat'};
49 0 return $user_info;
50 }
51 0 else{return undef}
52 }
53 1 1;
« Webqq/Client.pm ↑ Summary Webqq/Client/Method/_get_discuss_list_info.pm »