Webqq/Client/Method/_get_stranger_info.pm

filter: Statementstmt 25.9% 7 / 27 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 21.4% 9 / 42 CC 7 SCAR 37.8
CC
7
Cov
18%
_get_stranger_info
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 43.8
« Webqq/Client/Method/_send_group_message.pm ↑ Summary Webqq/Client/Method/_login2.pm »
1 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 0 ▶sub Webqq::Client::_get_stranger_info {
Subroutine _get_stranger_info: not called CC=7 SCAR=40.3
4 0 my $self = shift;
5 0 my $tuin = shift;
6 0 ▶ return undef if $self->{type} ne 'webqq';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type"} ne "webqq" 0 0 0
7 0 my $ua = $self->{ua};
8 0 my $cache_data = $self->{cache_for_stranger}->retrieve($tuin);
9 0 ▶ return $cache_data if defined $cache_data;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cache_data 0 0 0
10 0 my $api_url = 'http://s.web2.qq.com/api/get_stranger_info2';
11 0 my @headers = (
12 Referer => 'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=3',
13 'Content-Type'=>'utf-8',
14 );
15 my @query_string = (
16 tuin => $tuin,
17 verifysession => undef,
18 gid => 0,
19 code => undef,
20 vfwebqq => $self->{qq_param}{vfwebqq},
21 0 t => time,
22 );
23
24 0 my @query_string_pairs;
25 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
26 0 my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers);
27  
28 0 ▶ if($response->is_success){
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) { } 0 0 0
29 0 ▶ print $response->content(),"\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
30 0 my $json = JSON->new->utf8->decode($response->content());
31 0 ▶ return undef if $json->{retcode}!=0;
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"retcode"} != 0 0 0 0
32 0 $json->{result}{nick} = encode("utf8",$json->{result}{nick});
33 0 $self->{cache_for_stranger}->store($tuin,$json->{result},300);
34 0 return $json->{result};
35 }
36
37 0 else{return undef}
38 }
39 1 1;
« Webqq/Client/Method/_send_group_message.pm ↑ Summary Webqq/Client/Method/_login2.pm »